Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Toolbar overlays and casts a shadow on status bar

I'm using AppCompat for a backport of Material design on pre-Lollipop devices. Somehow, the support toolbar overlays the status bar and casts a shadow on it, as if the status bar is behind the toolbar. Tested on my Android 5.0.2 phone.

enter image description here

Here's the code:

Activity layout

<android.support.design.widget.CoordinatorLayout
    android:id="@+id/base_root"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:fitsSystemWindows="true">

    <android.support.design.widget.AppBarLayout
        android:id="@+id/base_appbar"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:theme="@style/PGTheme.AppBarOverlay">

        <android.support.v7.widget.Toolbar
            android:id="@+id/base_toolbar"
            android:layout_width="match_parent"
            android:layout_height="?attr/actionBarSize"
            android:background="?attr/colorPrimary"
            app:popupTheme="@style/PGTheme.PopupOverlay"/>

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

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

Theme-v21

<style name="PGTheme" parent="Theme.AppCompat.Light.DarkActionBar">
    <item name="colorPrimary">@color/base_color_2</item>
    <item name="colorPrimaryDark">@color/base_color_1</item>
    <item name="colorAccent">@color/base_color_2</item>
    <item name="android:colorButtonNormal">@color/base_color_2</item>
    <item name="android:textViewStyle">@style/PGTheme.TextView</item>
    <item name="android:editTextStyle">@style/PGTheme.EditText</item>
    <item name="android:buttonStyle">@style/PGTheme.Button</item>
</style>

<style name="PGTheme.NoActionBar">
    <item name="windowActionBar">false</item>
    <item name="windowNoTitle">true</item>
    <item name="android:windowDrawsSystemBarBackgrounds">true</item>
    <item name="android:statusBarColor">@android:color/transparent</item>
</style>

Any idea why this happens?

like image 436
Lucas Lages Avatar asked Dec 03 '15 23:12

Lucas Lages


1 Answers

In your Style remove the statusBarColor:

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

So your theme would be:

<style name="PGTheme.NoActionBar">
  <item name="windowActionBar">false</item>
  <item name="windowNoTitle">true</item>
  <item name="android:windowDrawsSystemBarBackgrounds">true</item>
</style>

Hope this helps.

like image 61
bond Avatar answered Sep 22 '22 20:09

bond