Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android : Toolbar status bar overlapping

I am working on creating an app with lollipop toolbar with translucent status bar to have the status bar also tinted. It is working fine with the true property.

It is just that the toolbar is overlapping with the status bar now which looks messy. What is the option to position the toolbar below the status bar with maintaining the window translucent status?

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

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

like image 899
sushant kunal Avatar asked Mar 02 '15 10:03

sushant kunal


People also ask

How do I show content behind the status bar?

You can show app content behind the status bar using SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN You should also use SYSTEM_UI_FLAG_LAYOUT_STABLE to help your app maintain stable layout.

What is Android Fitssystemwindows?

According to the official documentation it's a. Boolean internal attribute to adjust view layout based on system windows such as the status bar. If true, adjusts the padding of this view to leave space for the system windows.

What is the height of status bar in Android?

What is the size of status bar? Official height is 24dp , as is stated officially by Google on Android Design webpage. Save this answer.


2 Answers

as Virus correctly says, the answer is here: Toolbar overlapping below status bar

Simply add the attribute

android:fitsSystemWindows="true"

into the xml item and it will work fine :)

like image 115
Francesco Florio Avatar answered Oct 26 '22 23:10

Francesco Florio


I guess you are using fitSystemWindows property.

Turn off that.

like image 33
ytRino Avatar answered Oct 27 '22 01:10

ytRino