2

This problem how to deal with, Can someone deal with it,thanks a lot!

i set the windowTranslucentStatus true and the navigationDrawer is ok, but, my toolbar and system bar display together, so i use a library called systembartint to change the system bar's color and make the same with toolbar


and after i use it ,app become like this :

enter image description here

this time toolbar is ok ,but navigationDrawer is not ok , there is a background color at the top of navigationDrawer ,what i want to do is this :

enter image description here

can someone help me

rafsanahmad007
  • 23,683
  • 6
  • 47
  • 62
  • thanks @rafsanahmad007 for editing for my problem , this is my first time to ask a question in stackoverflow ,thanks again! – benjious chen Mar 23 '17 at 15:06
  • Possible duplicate of [Android DrawerLayout (with NavigationView) behind status bar](http://stackoverflow.com/questions/41501857/android-drawerlayout-with-navigationview-behind-status-bar) – Rajesh Mar 24 '17 at 05:05
  • @RajeshKushvaha thanks for you answering , but my device is API 19 ,it still can't work well – benjious chen Mar 25 '17 at 04:37

1 Answers1

0

If your phone is API 19 ,this is what i do ,first write your style

<style name="DayTheme" parent="Theme.AppCompat.Light.NoActionBar">
        <!-- Customize your theme here. -->
        <item name="colorPrimary">@color/primary</item>
        <item name="colorPrimaryDark">@color/primary_dark</item>
        <item name="colorAccent">@color/accent</item>
        <item name="background">@color/white</item>
        <item name="barTitleColor">@color/bar_title</item>
        <item name="barColor">@color/primary</item>
        <item name="textColor">@color/text_color</item>
        <item name="textLight">@color/text_light</item>
        <item name="textBright">@color/primary</item>
        <item name="dividerColor">@color/dividerColor</item>

    </style>

then the attr.xml :

<?xml version="1.0" encoding="utf-8"?>
<resources>
    <attr name="barTitleColor" format="color"/>
    <attr name="textColor" format="color"/>
    <attr name="textLight" format="color"/>
    <attr name="textBright" format="color"/>
    <attr name="dividerColor" format="color"/>
    <attr name="barColor" format="color"/>
</resources>

then my UI xml :

<?xml version="1.0" encoding="utf-8"?>
<android.support.design.widget.AppBarLayout
        xmlns:android="http://schemas.android.com/apk/res/android"
        xmlns:app="http://schemas.android.com/apk/res-auto"
        android:id="@+id/appbar"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:fitsSystemWindows="true"
        android:background="?attr/barColor"
        android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar"
        >

        <android.support.v7.widget.Toolbar
            app:contentInsetStart="0dp"
            android:id="@+id/toolbar"
            android:layout_width="match_parent"
            android:layout_height="?attr/actionBarSize"
            android:background="@color/colorPrimary"
            android:minHeight="?attr/actionBarSize"
            app:layout_scrollFlags="scroll|enterAlways"
            app:popupTheme="@style/ThemeOverlay.AppCompat.Light"
            app:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar"
            />

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

this is what i learn from Leisure,

android:background="?attr/barColor"
android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar"

this is one of answers, but i don't know why it can do it

  • TL;DR: Set `android:fitsSystemWindows="true"` on the AppBarLayout and DrawerLayout. – Eugen Pechanec Apr 11 '17 at 07:23
  • @EugenPechanec i ever had set ` android:fitsSystemWindows="true"`,but it don't work, [now i know why](http://stackoverflow.com/questions/27238433/when-should-one-use-theme-appcompat-vs-themeoverlay-appcompat) it can work :D – benjious chen Apr 12 '17 at 09:59