StatusBar上方的导航抽屉应为不透明

时间:2017-07-25 07:16:49

标签: android navigation styles statusbar

我能够在状态栏上方显示透明和半透明的导航抽屉,但我想,状态栏应该是完全不透明,背景应该是导航抽屉标题的完全白色。我没有使用默认导航抽屉活动,请不要建议我使用默认导航抽屉活动。

样式

<resources>

    <!-- Base application theme. -->
    <style name="AppTheme" parent="Theme.AppCompat.Light.NoActionBar">
        <!-- 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.AppBarOverlay" parent="ThemeOverlay.AppCompat.Dark.ActionBar" />
    <style name="AppTheme.PopupOverlay" parent="ThemeOverlay.AppCompat.Light" />


</resources>

样式-V21

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


    <style name="AppTheme" parent="Theme.AppCompat.Light.NoActionBar">
        <item name="colorPrimary">@color/colorPrimary</item>
        <item name="colorPrimaryDark">@color/colorPrimaryDark</item>
        <item name="colorAccent">@color/colorAccent</item>
        <item name="windowActionBar">false</item>
        <item name="windowActionModeOverlay">true</item>
        <item name="android:windowDrawsSystemBarBackgrounds">true</item>
        <item name="android:statusBarColor">@android:color/transparent</item>
        <item name="android:windowTranslucentStatus">true</item>

    </style>


</resources>

<?xml version="1.0" encoding="utf-8"?>
<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:openDrawer="start">


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

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

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


    </LinearLayout>

    <android.support.design.widget.NavigationView
        android:id="@+id/nav_view"
        android:layout_width="wrap_content"
        android:layout_height="match_parent"
        android:layout_gravity="start"
        android:background="#3EB7C2"
        android:fitsSystemWindows="true"
        android:visibility="visible">


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


            <RelativeLayout
                android:id="@+id/logoheader"
                android:layout_width="match_parent"
                android:layout_height="0dp"
                android:layout_weight="1.3"

                android:background="@mipmap/nav_header_logo" />

            <View
                android:layout_width="match_parent"
                android:layout_height="1dp"
                android:background="#FFFFFF" />

 </LinearLayout>


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


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

当android:fitsSystemWindows =“true”

enter image description here

当android:fitsSystemWindows =“false”

enter image description here

希望实现类似下面的背景颜色白色

enter image description here

  

导航抽屉可以完全在状态栏上方的Opqaue吗?

0 个答案:

没有答案