2015-11-29 60 views
4

我遇到了一個問題,我的狀態欄被推離我的工具欄。工具欄推開狀態欄

我想要的功能是當用戶向下滾動ListView時,工具欄消失在狀態欄後面,這樣只有選項卡可見,就像在WhatsApp和YouTube應用程序中一樣。

爲了達到這種效果,或者得到這個功能我用這條線:

app:layout_scrollFlags="scroll|enterAlways" 

到我android.support.v7.widget.Toolbar,但要知道,我以前說過,在狀態欄變得被推開。

enter image description here

enter image description here

enter image description here

<?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:id="@+id/main_content" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    android:fitsSystemWindows="true" 
    tools:context=".MainActivity"> 

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

     <android.support.v7.widget.Toolbar 
      android:id="@+id/toolbar" 
      android:layout_width="match_parent" 
      android:layout_height="?attr/actionBarSize" 
      app:layout_scrollFlags="scroll|enterAlways" 
      android:background="?attr/colorPrimary" 
      app:popupTheme="@style/AppTheme.PopupOverlay"> 

     </android.support.v7.widget.Toolbar> 

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

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

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


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

回答

2

我有同樣的問題,並設法解決它。只需刪除該行:

android:fitsSystemWindows="true" 

從協調器佈局。您可以在ViewPager中的佈局中進一步查看,但在頂層看來會導致該問題。

+0

當我試過這個解決方案時,狀態欄變成半透明白色,還有什麼更多的事情要做? –

相關問題