下面这个布局文件基本上描述了这几种Layout的用法。
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98
| <android.support.design.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" xmlns:app="http://schemas.android.com/apk/res-auto" android:id="@+id/coordinatorLayout" android:layout_width="match_parent" android:layout_height="match_parent" android:fitsSystemWindows="true" tools:context=".MainActivity" >
<android.support.design.widget.AppBarLayout android:id="@+id/appbar" android:layout_width="match_parent" android:layout_height="240dp" android:fitsSystemWindows="true" android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar" >
<android.support.design.widget.CollapsingToolbarLayout android:id="@+id/collapsing_toolbar" android:layout_width="match_parent" android:layout_height="match_parent" app:layout_scrollFlags="scroll|exitUntilCollapsed" android:fitsSystemWindows="true" app:contentScrim="?attr/colorPrimary" app:expandedTitleMarginEnd="64dp" app:expandedTitleMarginStart="48dp" >
<ImageView android:id="@+id/backdrop" android:layout_width="match_parent" android:layout_height="match_parent" app:layout_collapseMode="parallax" android:fitsSystemWindows="true" android:scaleType="centerCrop" app:layout_scrollFlags="scroll|enterAlways|enterAlwaysCollapsed" android:src="@drawable/ic_launcher" />
<android.support.v7.widget.Toolbar android:id="@+id/toolbar" android:layout_width="match_parent" android:layout_height="?attr/actionBarSize" app:layout_collapseMode="pin" app:layout_scrollFlags="scroll|enterAlways" app:titleTextAppearance="@style/TextAppearance.AppCompat.Headline" app:popupTheme="@style/ThemeOverlay.AppCompat.Dark" />
</android.support.design.widget.CollapsingToolbarLayout> </android.support.design.widget.AppBarLayout>
<android.support.v7.widget.RecyclerView android:id="@+id/recyclerView" android:layout_width="match_parent" android:layout_height="match_parent" app:layout_behavior="@string/appbar_scrolling_view_behavior" />
<android.support.design.widget.FloatingActionButton android:id="@+id/floatingActionButton" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_margin="16dp" android:src="@drawable/ic_launcher" app:fabSize="normal" app:backgroundTint="#CCCC00" app:elevation="16dp" app:layout_anchor="@id/recyclerView" app:layout_behavior="com.mb.widget.ScrollAwareFABBehavior" app:layout_anchorGravity="bottom|right|end"/>
<android.support.design.widget.FloatingActionButton android:layout_width="wrap_content" android:layout_height="wrap_content" android:src="@drawable/ic_launcher" app:fabSize="normal" app:backgroundTint="#CC00CC" app:layout_anchor="@id/appbar" app:layout_anchorGravity="bottom|right|end"/>
</android.support.design.widget.CoordinatorLayout>
|