2016-07-19 6 views
1

Я использую NavigationView с панелью инструментов. Фон панели состояния - белый. Если у вас есть какие-либо вопросы, просто прокомментируйте это до начала опроса, я посмотрю на них как можно скорее.Строка состояния становится белой при использовании пользовательской панели инструментов

activity_main.xml

<android.support.v4.widget.DrawerLayout 
xmlns:android="http://schemas.android.com/apk/res/android" 
xmlns:app="http://schemas.android.com/apk/res-auto" 
android:id="@+id/drawer_layout" 
android:layout_width="match_parent" 
android:layout_height="match_parent"> 

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

    <include 
     layout="@layout/app_bar_main" 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" /> 

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

<android.support.design.widget.NavigationView 
    android:id="@+id/nvView" 
    android:layout_width="wrap_content" 
    android:layout_height="match_parent" 
    android:layout_gravity="start" 
    android:background="@android:color/white" 
    app:headerLayout="@layout/nav_header_main" 
    app:menu="@menu/activity_main_drawer/> 
    </android.support.v4.widget.DrawerLayout> 

app_bar_main.xml

<android.support.v7.widget.Toolbar 
xmlns:android="http://schemas.android.com/apk/res/android" 
xmlns:app="http://schemas.android.com/apk/res-auto" 
android:id="@+id/toolbar" 
android:layout_height="wrap_content" 
android:layout_width="match_parent" 
android:fitsSystemWindows="true" 
android:minHeight="?attr/actionBarSize" 
app:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar" 
android:background="?attr/colorPrimaryDark"> 
</android.support.v7.widget.Toolbar> 

styles.xml

<resources> 

<!-- Base application theme. --> 
<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar"> 
    <!-- Customize your theme here. --> 
    <item name="colorPrimary">@color/colorPrimary</item> 
    <item name="colorPrimaryDark">@color/colorPrimaryDark</item> 
    <item name="colorAccent">@color/colorAccent</item> 
</style> 

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

<style name="AppTheme.AppBarOverlay" parent="ThemeOverlay.AppCompat.Dark.ActionBar" /> 

<style name="AppTheme.PopupOverlay" parent="ThemeOverlay.AppCompat.Light" /> 

colors.xml

<resources> 
    <color name="colorPrimary">#3F51B5</color> 
    <color name="colorPrimaryDark">#303F9F</color> 
    <color name="colorAccent">#FF4081</color> 
</resources> 
+1

Попробуйте что-то вроде: 'андроида: fitsSystemWindows = "ложь"' – ArbenMaloku

+0

Как же вы определили @ цвет/colorPrimaryDark (в colors.xml)? – W0rmH0le

+0

Загрузить файл color.xml –

ответ

2

Вы должны добавить этот атрибут андроида: fitsSystemWindows = "истинный" в родителя (DrawerLayout). Чтобы зафиксировать белую полосу статуса во время ее использования.

Чтобы узнать больше об этом см ссылке Why would I want to fitsSystemWindows?

<android.support.v4.widget.DrawerLayout xmlns:android="http://schemas.android.com/apk/res/android" 
xmlns:app="http://schemas.android.com/apk/res-auto" 
android:id="@+id/drawer" 
android:layout_width="match_parent" 
android:layout_height="match_parent" 
android:fitsSystemWindows="true"> 

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

    <include 
     android:id="@+id/toolbar" 
     layout="@layout/tool_bar" /> 

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

</LinearLayout> 

<android.support.design.widget.NavigationView 
    android:id="@+id/navigation" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    android:layout_gravity="start" 
    app:headerLayout="@layout/navigation_header" 
    app:itemTextColor="@color/primary_dark" 
    app:menu="@menu/my_navigation_items" /> 

+0

Вау, это так просто? Большое спасибо. –

+0

Да, очень просто – JUL2791