2015-08-25 80 views
5

我有TabLayout崩潰ToolbarLayout,除了我的標籤都沒有得到貼在下面的工具欄上的向上滾動一切工作正常。如何使用摺疊式工具的佈局和TabLayout貼標籤下方工具欄

下面是我的代碼:

<?xml version="1.0" encoding="utf-8"?> 

<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:fitsSystemWindows="true"> 

    <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" 
     app:expandedTitleTextAppearance="@style/TransparentText"> 

     <FrameLayout 
      android:id="@+id/carouselLayout" 
      android:layout_width="match_parent" 
      android:layout_height="match_parent" 
      android:fitsSystemWindows="true" 
      app:layout_collapseMode="parallax"> 

      <ImageView 
       android:id="@+id/coverImage" 
       android:layout_width="match_parent" 
       android:layout_height="match_parent" 
       android:scaleType="centerCrop"/> 

      <LinearLayout 
       android:layout_width="match_parent" 
       android:gravity="bottom" 
       android:orientation="vertical" 
       android:layout_gravity="bottom" 
       app:layout_behavior="@string/appbar_scrolling_view_behavior" 
       android:layout_height="wrap_content"> 

       <TextView 
        android:layout_width="match_parent" 
        android:layout_height="wrap_content" 
        android:layout_marginLeft="@dimen/profile_image_margin" 
        android:textSize="@dimen/text_size_xlarge" 
        android:textStyle="bold" 
        android:padding="@dimen/profile_image_margin" 
        android:shadowColor="@color/text_shadow" 
        android:shadowDx="1" 
        android:shadowDy="1" 
        android:shadowRadius="2" 
        android:textColor="@color/white" 
        android:id="@+id/content_title"/> 

       <android.support.design.widget.TabLayout 
        android:id="@+id/slidingTabs" 
        android:layout_width="match_parent" 
        app:tabMode="scrollable" 
        app:layout_collapseMode="pin" 
        android:background="@drawable/gradient_bg" 
        app:tabGravity="fill" 
        app:layout_scrollFlags="scroll" 
        android:layout_height="wrap_content"/> 

      </LinearLayout> 

     </FrameLayout> 

     <android.support.v7.widget.Toolbar 
      android:id="@+id/toolbar" 
      android:layout_width="match_parent" 
      android:layout_height="?attr/actionBarSize" 
      app:theme="@style/ActionBarThemeOverlay" 
      app:popupTheme="@style/ActionBarPopupThemeOverlay" 
      app:layout_collapseMode="pin" 
      android:background="@drawable/gradient_bg" /> 

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

<android.support.v4.view.ViewPager 
    android:id="@+id/pager" 
    android:layout_width="match_parent" 
    app:layout_behavior="@string/appbar_scrolling_view_behavior" 
    android:layout_height="wrap_content"> 

</android.support.v4.view.ViewPager> 

請幫助我,我怎麼能做到這一點。非常感謝你在先進。

回答

0
<android.support.v7.widget.Toolbar 
       android:id="@+id/anim_toolbar" 
       android:layout_width="match_parent" 
       android:layout_height="100dp" 
       android:gravity="top" 
       android:minHeight="?attr/actionBarSize" 
       app:layout_collapseMode="pin" 
       app:titleMarginTop="15dp" /> 

嘗試This..It可以幫助你..

相關問題