我已应用以下内容。因此,当打开导航抽屉时,状态栏颜色看起来是黑色的。但是我的问题在哪里?它为状态栏的整个宽度着色,我希望他直到导航抽屉打开的部分颜色。我该如何解决这个问题?
<style name="AppBaseTheme2" parent="Theme.AppCompat.Light.DarkActionBar"> <item name="android:colorAccent">@color/pink</item> <item name="android:colorPrimaryDark">@color/pink</item> <item name="android:colorPrimary">@color/pink</item> <item name="colorPrimary">@color/pink</item> <item name="colorPrimaryDark">@color/pink</item> <item name="colorAccent">@color/pink</item> <item name="android:dialogTheme">@style/DialogTheme</item> <item name="windowActionBar">false</item> <item name="windowNoTitle">true</item> <!-- We will be using the toolbar so no need to show ActionBar --> <item name="android:windowActionBar">false</item> <item name="android:windowDrawsSystemBarBackgrounds">true</item> <item name="android:statusBarColor">@android:color/black</item> </style>
<?xml version="1.0" encoding="utf-8"?>
<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"
android:fitsSystemWindows="true">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<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_width="match_parent"
android:layout_height="wrap_content"
android:background="@color/purple"
android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar"
app:popupTheme="@style/ThemeOverlay.AppCompat.Light"
app:titleTextAppearance="@style/ToolbarTitle"></android.support.v7.widget.Toolbar>
<FrameLayout
android:id="@+id/frame_container"
android:layout_width="match_parent"
android:layout_height="match_parent" />
</LinearLayout>
<LinearLayout
android:id="@+id/line1"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_gravity="start"
android:fitsSystemWindows="true"
android:orientation="vertical">
<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:fitsSystemWindows="true"
app:menu="@menu/activity_main_drawer" />
</LinearLayout>
</android.support.v4.widget.DrawerLayout>
答案 0 :(得分:0)
试试这个主题
<!-- Base application theme. -->
<style name="Base.MyTheme" 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="windowActionBarOverlay">true</item>
<item name="windowNoTitle">true</item>
<item name="android:windowBackground">@color/colorPrimary</item>
</style>