简体   繁体   English

导航抽屉上的状态栏颜色

[英]Status Bar Color on navigation drawer

I have applied the following. 我已经应用了以下内容。 So when the navigation drawer is opened, the status bar color looks black.But where is my problem? 因此,当打开导航抽屉时,状态栏颜色看起来是黑色,但是我的问题在哪里呢? It is coloring the whole width of the status bar, I want him to color just until the part the navigation drawer is open.How can I work this out? 它正在对状态栏的整个宽度进行着色,我希望他仅对导航抽屉打开的部分进行着色。如何解决?

  <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>

Try this theme 试试这个主题

<!-- 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>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM