Android Design Support Library 02-collapsingtoolbarlayout&&cardview

Source: Internet
Author: User

The second update of Material design! This time, two controls Collapsingtoolbarlayout&&cardview

1, Collapsingtoolbarlayout

After 5.0, the app for folding has appeared, and Google introduced the control in the design of material in the previous period.
Ok, or first on the video!

The code is as follows Copy Code
<android.support.design.widget.appbarlayout
Android:layout_width= "Match_parent"
android:layout_height= "256DP"
Android:fitssystemwindows= "true" >
<android.support.design.widget.collapsingtoolbarlayout
Android:id= "@+id/collapsing_toolbar_layout"
Android:layout_width= "Match_parent"
android:layout_height= "Match_parent"
App:contentscrim= "#30469b"
App:expandedtitlemarginstart= "48DP"
app:layout_scrollflags= "scroll|exituntilcollapsed" >

<imageview
Android:layout_width= "Match_parent"
android:layout_height= "Match_parent"
Android:scaletype= "Centercrop"
android:src= "@mipmap/BG"
App:layout_collapsemode= "Parallax"
app:layout_collapseparallaxmultiplier= "0.7"/>

<android.support.v7.widget.toolbar
Android:id= "@+id/toolbar"
Android:layout_width= "Match_parent"
Android:layout_height= "Attr/actionbarsize"?
App:layout_collapsemode= "Pin"/>
</android.support.design.widget.CollapsingToolbarLayout>
</android.support.design.widget.AppBarLayout>

Official hints, using collasingtoolbarlayout and Toolbar,title with Collapsingtoolbar to set
This setup uses Collapsingtoolbarlayout's app:layout_collapsemode= "pin" to ensure that the Toolbar itself remains pinned T o The top of the screens while the view collapses. Even better, when your use Collapsingtoolbarlayout and Toolbar together, the title would automatically appear when th E layout is fully visible, then transition to its default size as it is collapsed. Note this in those cases, your should call Settitle () on the collapsingtoolbarlayout, rather than on the Toolbar itself.

2, CardView

It implements a card-type and has a shaded effect.

The code is as follows Copy Code

<android.support.v7.widget.cardview
Android:layout_width= "Match_parent"
android:layout_height= "Wrap_content"
android:layout_margin= "@dimen/card_margin" >

<linearlayout
style= "@style/widget.cardcontent"
Android:layout_width= "Match_parent"
android:layout_height= "Wrap_content" >

<textview
Android:layout_width= "Match_parent"
android:layout_height= "Wrap_content"
Android:text= "Inaifan (かいづかいなほ)"
Android:textappearance= "@style/textappearance.appcompat.title"/>

<textview
Android:layout_width= "Match_parent"
android:layout_height= "Wrap_content"
Android:text= "Hero. Live in the ground ... "/>

<imageview
Android:id= "@+id/iv_ynf"
Android:layout_width= "Wrap_content"
android:layout_height= "Wrap_content"/>

</LinearLayout>
</android.support.v7.widget.CardView>

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.