android studio|Android Design Support Library 02 ― CollapsingToolbarLayout&&CardView

更新时间:2020-03-12    来源:今天更新    手机版     字体:

【www.bbyears.com--今天更新】

Material Design的第二篇更新啦!这次介绍两个控件CollapsingToolbarLayout&&CardView

1、CollapsingToolbarLayout

5.0之后,折叠效果的App出现了,前段时间google在material design的设计中也推出了这个控件。
Ok,还是先上视频

 代码如下         android:layout_width="match_parent"
        android:layout_height="256dp"
        android:fitsSystemWindows="true">
                    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">
  
                            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:id="@+id/toolbar"
                android:layout_width="match_parent"
                android:layout_height="?attr/actionBarSize"
                app:layout_collapseMode="pin" />
       
   

官方提示,使用CollasingToolbarLayout和Toolbar,title用CollapsingToolbar来设置
This setup uses CollapsingToolbarLayout’s app:layout_collapseMode=”pin” to ensure that the Toolbar itself remains pinned to the top of the screen while the view collapses. Even better, when you use CollapsingToolbarLayout and Toolbar together, the title will automatically appear larger when the layout is fully visible, then transition to its default size as it is collapsed. Note that in those cases, you should call setTitle() on the CollapsingToolbarLayout, rather than on the Toolbar itself.

2、CardView

实现了卡片式的并且有阴影效果。

 代码如下

       android:layout_width="match_parent"
       android:layout_height="wrap_content"
       android:layout_margin="@dimen/card_margin">
 
                  style="@style/Widget.CardContent"
           android:layout_width="match_parent"
           android:layout_height="wrap_content">
 
                          android:layout_width="match_parent"
               android:layout_height="wrap_content"
               android:text="界冢伊奈帆(かいづか いなほ)"
               android:textAppearance="@style/TextAppearance.AppCompat.Title" />
 
                          android:layout_width="match_parent"
               android:layout_height="wrap_content"
               android:text="主人公。居住在地..." />
 
                          android:id="@+id/iv_ynf"
               android:layout_width="wrap_content"
               android:layout_height="wrap_content" />
 
      

本文来源:http://www.bbyears.com/jintiangengxin/86560.html

热门标签

更多>>

本类排行