有关CoordinatorLayout的总结

来源:互联网 发布:51单片机简易电子琴 编辑:程序博客网 时间:2024/06/03 11:17
1.BottomSheet <android.support.design.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android"    xmlns:tools="http://schemas.android.com/tools"    android:id="@+id/activity_main"    android:layout_width="match_parent"    android:layout_height="match_parent"    xmlns:app="http://schemas.android.com/apk/res-auto"    tools:context="com.example.lianxiday_071302.MainActivity">    <TextView        android:layout_width="match_parent"        android:layout_height="match_parent"        android:text="Hello World!" />    <RelativeLayout        app:behavior_hideable="false"        app:behavior_peekHeight="200dp"        android:background="@color/colorAccent"        app:layout_behavior="@string/bottom_sheet_behavior"        android:layout_width="match_parent"        android:layout_height="match_parent">        <ListView            android:id="@+id/lv"            android:layout_width="match_parent"            android:layout_height="match_parent" />    </RelativeLayout></android.support.design.widget.CoordinatorLayout>![效果图](http://img.blog.csdn.net/20170713142638168?watermark/2/text/aHR0cDovL2Jsb2cuY3Nkbi5uZXQveGlhb3NoaXRvdW5hbg==/font/5a6L5L2T/fontsize/400/fill/I0JBQkFCMA==/dissolve/70/gravity/SouthEast)2.Toolbar的收缩与扩展注意:如果是listview或gridview需要在listview中加上属性:android:nestedScrollingEnabled="true"布局:<android.support.design.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android"    xmlns:tools="http://schemas.android.com/tools"    android:id="@+id/activity_main"    android:layout_width="match_parent"    android:layout_height="match_parent"    xmlns:app="http://schemas.android.com/apk/res-auto"    tools:context="com.example.lianxiday_071302.MainActivity">    <android.support.design.widget.AppBarLayout        android:id="@+id/appbar"        android:layout_width="match_parent"        android:layout_height="wrap_content"        android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar">        <android.support.v7.widget.Toolbar            android:id="@+id/toolbar"            android:layout_width="match_parent"            android:layout_height="?attr/actionBarSize"            android:background="?attr/colorPrimary"            app:layout_scrollFlags="scroll|enterAlways"            app:popupTheme="@style/ThemeOverlay.AppCompat.Light"/>    </android.support.design.widget.AppBarLayout>        <ListView            app:layout_behavior="@string/appbar_scrolling_view_behavior"            android:id="@+id/lv"            android:nestedScrollingEnabled="true"            android:layout_width="match_parent"            android:layout_height="match_parent" /></android.support.design.widget.CoordinatorLayout>3.viewpager实现把上面图片推上去的效果