2016-09-07 4 views
2

android:windowLightStatusBartrueには、私のアプリ内のステータスバーに黒いアイコンとテキストを下の画像で表示するように設定しました。アンドロイド:windowLightStatusBarとナビゲーションドロワーの間の問題

enter image description here

しかし、もはやフィット画面へのナビゲーションドロワーは、以下の絵を見ません。これは、android:windowLightStatusBarが確実に動作するように、android:windowTranslucentStatusをfalseに設定する必要があるためです。回避策はありますか? Googleカレンダーのようなアプリはこの機能でうまくいくようです。

enter image description here

ここに私の主な活動のXML

<android.support.v4.widget.DrawerLayout 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/drawer_layout" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    android:background="@color/colorToolbarBackground" 
    android:fitsSystemWindows="true" 
    > 

    <LinearLayout 
     android:layout_width="match_parent" 
     android:layout_height="match_parent" 
     android:orientation="vertical"> 

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

     <FrameLayout 
      android:id="@+id/frame" 
      android:layout_width="match_parent" 
      android:layout_height="match_parent" /> 
    </LinearLayout> 


    <android.support.design.widget.NavigationView 

     android:id="@+id/navigation_view" 
     android:background="@color/colorWhite" 
     android:layout_width="wrap_content" 
     android:layout_height="match_parent" 
     android:layout_gravity="start" 

     app:menu="@menu/navigation_view_items" /> 

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

ている必要がありますか? –

+0

はい、Googleカレンダーのように –

+0

layout.xmlを追加してください –

答えて

1

layout.xml

android:fitsSystemWindows="true" 

からこの行を削除し、styles-v21.xml

にこれを追加しています Manifest.xml
<style name="AppTheme.NoActionBar"> 
    <item name="windowActionBar">false</item> 
    <item name="windowNoTitle">true</item> 
    <item name="android:windowDrawsSystemBarBackgrounds">true</item> 
    <item name="android:statusBarColor">@android:color/transparent</item> 
</style> 

styles.xml

<style name="AppTheme.NoActionBar"> 
    <item name="windowActionBar">false</item> 
    <item name="windowNoTitle">true</item> 
</style> 

あなたの活動にこれを追加し、メイン

android:theme="@style/AppTheme.NoActionBar" 

そして、これにAppBarLayoutタグをラップ:

<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=".MainActivity"> 

    <!-- Here AppBarLayout ecc --> 

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

<!-- Here NavigationView ecc --> 

AppBarLayoutあなたがステータスバーに重なっNavigationDrawerたい

android:theme="@style/AppTheme.AppBarOverlay" 
+0

すべての手順を実行してもまだ動作しません。 –

+0

私は編集しました今すぐ確認してください –

+0

それは今動作します、あなたは天才です、なぜCoordinatorLayoutでラップするとうまくいくのか説明できますか? –

関連する問題