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> |