1

在我的應用程序中,我使用AppBarLayoutToolbar作爲我的支持操作欄。我希望它在用戶滾動內容時隱藏/顯示。在KitKat上一切正常,但在棒棒糖和棉花糖工具欄上沒有滾動其全高。 Screen with toolbar fully scrolledAndroid工具欄沒有完全隱藏(> Lollipop)

我的佈局:

<android.support.v4.widget.DrawerLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    xmlns:tools="http://schemas.android.com/tools" 
    android:id="@+id/drawer_layout" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    android:fitsSystemWindows="true" 
    tools:context="(...)"> 

    <include 
     android:id="@+id/app__content" 
     layout="@layout/app_bar__main" 
     android:layout_width="match_parent" 
     android:layout_height="match_parent" /> 

    <fragment android:id="@+id/navigation_drawer" 
     android:layout_width="@dimen/navigation_drawer_width" 
     android:layout_height="match_parent" 
     android:layout_gravity="left" 
     android:fitsSystemWindows="true" 
     android:name="(...)" 
     tools:layout="@layout/fragment__navigation_drawer" /> 

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

app_bar__main.xml

<?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="(...)"> 

    <android.support.design.widget.AppBarLayout 
     android:id="@+id/app__appbarlayout__action_bar_layout" 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:theme="@style/AppTheme.AppBarOverlay"> 

     <android.support.v7.widget.Toolbar 
      android:id="@+id/app__toolbar" 
      android:layout_width="match_parent" 
      android:layout_height="@dimen/action_bar__height" 
      android:background="@drawable/toolbar__background" 
      android:elevation="4dp" 
      app:layout_scrollFlags="scroll|enterAlways" 
      app:popupTheme="@style/AppTheme.PopupOverlay" 
      tools:ignore="UnusedAttribute" /> 

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

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

    <include android:id="@+id/app__layout__bottom_bar" 
     layout="@layout/layout__bottom_bar" /> 

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

app_content__main.xml只是FrameLayout裏成我加入片段。我使用support:appcompat-v7:23.3.0support:design:23.2.0(由於工具欄存在另一個錯誤,因此無法使用23.3.0)。它與23.0.0一起工作,但是有什麼辦法可以在不移動到以前的版本的情況下工作嗎?

回答

1

您必須從CoordinatorLayout中刪除android:fitsSystemWindows =「true」。