2016-07-22 53 views
0

我有一個活動包含2個片段作爲製表符佈局當我觸摸第一個片段(選項卡)它需要滾動其工作正常,但當我觸摸第二個片段(選項卡)我不要崩潰的工具欄佈局只有兩個片段的標籤,我想在這片以幫助我,如果你知道this.XML含隱藏父級活動collapsingToolbar佈局從子片段

enter code here 

<android.support.design.widget.AppBarLayout 
    android:layout_width="match_parent" 
    android:layout_height="wrap_content" 
    android:fitsSystemWindows="true" 
    android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar"> 


    <android.support.design.widget.CollapsingToolbarLayout 
     android:id="@+id/collapse_toolbar" 
     android:layout_width="match_parent" 
     android:layout_height="250dp" 
     android:fitsSystemWindows="true" 
     app:contentScrim="?attr/colorPrimary" 
     app:layout_scrollFlags="scroll|exitUntilCollapsed"> 


     <ImageView 
      android:id="@+id/header" 
      android:layout_width="match_parent" 
      android:layout_height="match_parent" 
      android:background="#424242" 
      android:fitsSystemWindows="true" 
      android:scaleType="centerCrop" 

      app:layout_collapseMode="parallax" /> 

     <android.support.v7.widget.Toolbar 
      android:id="@+id/toolbar" 
      android:layout_width="match_parent" 
      android:layout_height="wrap_content" 
      android:gravity="top" 

app:layout_collapseMode="pin" 
      /> 


     <Relative-layout 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      "> 

      <Text-view 
      /> 

     <Text-view 

       /> 

      <View 
       android:id="@+id/view" 
       android:layout_width="wrap_content" 
       android:layout_height="2dp" 
       /> 

      <Image View 

      /> 

     </RelativeLayout> 

     <android.support.design.widget.TabLayout 
      android:id="@+id/tabs 
      android:layout_gravity="bottom" 
      /> 

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

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


<android.support.v4.view.ViewPager 

    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    app:layout_behavior="@string/appbar_scrolling_view_behavior" /> 

<android.support.design.widget.FloatingActionButton 

    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    android:layout_gravity="bottom|end" 
    /> 

回答

0

設置一個TabSelected偵聽器,並在選擇第二個選項卡時,通過appBarLayout.SetExpanded(false, true);摺疊工具欄,並將其高度設置得較小。
參見herehere