2016年8月11日 星期四

How to zero applayout height with CoordinatorLayout?

42 How to zero applayout height with CoordinatorLayout?

<?xml version="1.0" encoding="utf-8"?>
<android.support.design.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android"
   xmlns:app="http://schemas.android.com/apk/res-auto"
   xmlns:tools="http://schemas.android.com/tools"
   android:layout_width="match_parent"
   android:layout_height="match_parent"
   android:fitsSystemWindows="true"
   tools:context="pom.poly.com.myapplication.ScrollingActivity">

   <android.support.design.widget.AppBarLayout
       android:id="@+id/app_bar"
       android:layout_width="match_parent"
       android:layout_height="@dimen/app_bar_height"
       android:fitsSystemWindows="true"
       android:theme="@style/AppTheme.AppBarOverlay">


       <android.support.design.widget.CollapsingToolbarLayout
           android:id="@+id/toolbar_layout"
           android:layout_width="match_parent"
           android:layout_height="0dp"
           android:layout_weight="1"
           android:fitsSystemWindows="true"
           app:contentScrim="?attr/colorPrimary"
           app:layout_scrollFlags="scroll">

           <android.support.v7.widget.Toolbar
               android:id="@+id/toolbar"
               android:layout_width="match_parent"
               android:layout_height="?attr/actionBarSize"
               android:minHeight="0dp"

               />
           <!--app:layout_collapseMode="pin"-->
           <!--app:popupTheme="@style/AppTheme.PopupOverlay"-->
       </android.support.design.widget.CollapsingToolbarLayout>

       <Button
           android:layout_width="match_parent"
           android:layout_height="0dp"
           android:layout_weight="1"
           android:text="Button"
           app:layout_scrollFlags="scroll|enterAlways" />
   </android.support.design.widget.AppBarLayout>

   <include layout="@layout/content_scrolling" />


</android.support.design.widget.CoordinatorLayout>


<?xml version="1.0" encoding="utf-8"?>
<android.support.v4.widget.NestedScrollView xmlns:android="http://schemas.android.com/apk/res/android"
   xmlns:app="http://schemas.android.com/apk/res-auto"
   xmlns:tools="http://schemas.android.com/tools"
   android:layout_width="match_parent"
   android:layout_height="match_parent"
   app:layout_behavior="@string/appbar_scrolling_view_behavior"
   tools:context="pom.poly.com.myapplication.ScrollingActivity"
   tools:showIn="@layout/activity_scrolling">

   <TextView
       android:layout_width="wrap_content"
       android:layout_height="wrap_content"
       android:layout_margin="@dimen/text_margin"
       android:text="@string/large_text" />

</android.support.v4.widget.NestedScrollView>