Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

fitsSystemWindows not making the status bar transparent

Tags:

android

I had an ConstraintLayout and I want to include the Collapsing Toolbar Layout in it. So, I followed this tutorial: https://antonioleiva.com/collapsing-toolbar-layout/

But, my status bar is not transparent, even after including fitsSystemWindows in almost every component in my XML.

Here's my style, used in the activity

<style name="AppTheme2" parent="Theme.AppCompat.Light.NoActionBar">
    <!-- Customize your theme here. -->
    <item name="colorPrimary">@color/colorPrimary</item>
    <item name="colorPrimaryDark">@color/colorPrimaryDark</item>
    <item name="colorAccent">@color/colorAccent</item>
</style>

The XML layout is too big, so I put it on this gist: https://gist.github.com/guuilp/6e20ff9e00af8b85c858c5e832a17c34

Furthermore, the back button is not being shown too.

like image 424
Guilherme Lima Pereira Avatar asked Feb 22 '17 21:02

Guilherme Lima Pereira


People also ask

What is fitsSystemWindows in android?

That's what the default behavior of the android:fitsSystemWindows="true" attribute gives you: it sets the padding of the View to ensure the contents don't overlay the system windows.


1 Answers

Add the below to your theme, note that this requires minSdkVersion to be 19.

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

Then set android:fitsSystemWindows=”true” in the Activity where you want the transparent status bar.

like image 120
Drew Szurko Avatar answered Oct 22 '22 19:10

Drew Szurko