Android: toolbar status bar overlaps

I am working on creating an application with a lollipop panel with a translucent status panel so that the status bar also displays. It works fine with true.

It's just that the toolbar overlaps with a status bar that looks dirty. What is the option of positioning the toolbar under the status bar while maintaining the status of a translucent window?

Code snippets:

<style name="Theme.XXX" parent="Theme.AppCompat"> <item name="colorPrimary">...</item> <item name="colorPrimaryDark">...</item> <item name="android:windowTranslucentStatus">true</item> <item name="windowActionBar">false</item> <item name="colorAccent">...</item> </style> 

Toolbar code used in the action:

 <android.support.v7.widget.Toolbar android:id="@+id/main_toolbar" android:layout_width="match_parent" android:layout_height="wrap_content" android:background="@color/XXX" android:elevation="5dp" android:minHeight="?attr/actionBarSize" android:theme="@style/Theme.XXX" /> 

Thanks in advance.

+7
android android-5.0-lollipop android-4.4-kitkat
source share
5 answers

as the virus correctly says, the answer is: the toolbar overlaps below the status bar

Just add attribute

Android: fitsSystemWindows = "true"

into the xml element and it will work fine :)

+10
source share

I assume that you are using the fitSystemWindows property.

Turn it off.

+1
source share

Maybe your topic has this

  <item name="android:statusBarColor">@android:color/transparent</item> 

to comment

+1
source share

Just add this to v21 / styles.xml

 <item name="android:windowDrawsSystemBarBackgrounds">false</item> <item name="android:statusBarColor">@android:color/transparent</item> 
0
source share

To maintain a translucent status, you need to

 <item name="android:windowTranslucentStatus">true</item> 

Just make below false

 <item name="android:windowDrawsSystemBarBackgrounds">false</item> 

and in the parent layout

 android:fitsSystemWindows="true" 
0
source share

All Articles