2016-10-11 135 views
1

我想在我的片段中实现折叠布局。但是我的collapsingLayout,framelayout(容器)和tablayout像放置在框架布局中一样放置。
我想在顶部使用Collapsinglayout,在tablayout下面使用tablayout,在tablayout下面使用框架布局,保留折叠的注释。 (帧布局容器主机[因为varioius定制的手势,viewpager不被认为是]由recyclerview的各种片段)如何在协调器中垂直放置布局布局

fragment_layout.xml

<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:background="@color/appBgColor" 
    android:clickable="true" 
    tools:context="com.lunchpoint.fragments.RestaurantFragment" 

    > 
    <android.support.design.widget.AppBarLayout 
     android:id="@+id/id_appbar" 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:background="@android:color/transparent" 
     android:fitsSystemWindows="true" 
     > 

    <android.support.design.widget.CollapsingToolbarLayout 
     android:layout_width="match_parent" 
     android:layout_height="match_parent" 
     android:fitsSystemWindows="true" 
     app:contentScrim="?attr/colorPrimary" 
     app:expandedTitleMarginEnd="64dp" 
     app:expandedTitleMarginStart="48dp" 
     app:layout_scrollFlags="scroll|exitUntilCollapsed" 
     > 

     <RelativeLayout 
      android:layout_width="match_parent" 
      android:layout_height="310dip" 
      > 
     <!--Header layout--> 
     </RelativeLayout> 

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

    </android.support.design.widget.AppBarLayout> 
    <android.support.design.widget.TabLayout 
     android:id="@+id/tabs" 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 

     android:layout_marginEnd="16dip" 
     android:layout_marginLeft="16dip" 
     android:layout_marginRight="16dip" 
     android:layout_marginStart="16dip" 
     app:tabGravity="fill" 
     app:tabMinWidth="0dip" 
     app:tabMode="scrollable" 
     app:tabPaddingEnd="1dp" 
     app:tabPaddingStart="1dp" 
     /> 

    <FrameLayout 

     android:id="@+id/container" 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     /> 

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

回答

0

CoordinatorLayout是电动的FrameLayout:所有儿童的可限定它们的位置通过行为或锚点。查看更多文档,如​​。