Overlay the toolbar and cast a shadow on the status bar

I use AppCompat to back up material design on pre-Lollipop devices. Somehow, the support of the toolbar imposes a status bar and casts a shadow on it, as if the status bar is behind the toolbar. Tested on my Android 5.0.2.

enter image description here

Here is the code:

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

Layer-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 is happening?

+5
source share
1 answer

In your style, remove statusBarColor:

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

So your subject:

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

Hope this helps.

+10
source

Source: https://habr.com/ru/post/1237368/


All Articles