7

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.

Sushant kunal
  • 341
  • 1
  • 2
  • 9

6 Answers6

12

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

Community
  • 1
  • 1
Francesco Florio
  • 1,184
  • 14
  • 16
  • 4
    I would not recommend this because there is some side effects with the toast and because the status bar will actually choose a gray color and I'm guessing devs don't want that if they have color for it already. take a better look in this [read](https://code.google.com/p/android/issues/detail?id=63653) – Rensodarwin Sep 22 '15 at 04:04
  • If i have xaml page than what parameter i have to set? – Parin Parikh May 06 '17 at 06:29
2

I guess you are using fitSystemWindows property.

Turn off that.

ytRino
  • 1,450
  • 15
  • 28
1

May be your theme has this

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

comment it out

g_vk
  • 106
  • 7
1

In order to keep translucent status, you need to have

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

Just make the below false

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

and in your parent layout

android:fitsSystemWindows="true"
Aveek
  • 849
  • 1
  • 12
  • 28
0

Just add this to v21/styles.xml file

<item name="android:windowDrawsSystemBarBackgrounds">false</item>
<item name="android:statusBarColor">@android:color/transparent</item>
djubreel
  • 5
  • 1
  • 2
0

Simply remove from all xmls, where it can be found, tag. fitsSystemWindows
Or set it to false.