Guilherme Lima Pereira
Guilherme Lima Pereira

Reputation: 1434

fitsSystemWindows not making the status bar transparent

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.

Upvotes: 6

Views: 5371

Answers (1)

Drew Szurko
Drew Szurko

Reputation: 1621

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.

Upvotes: 9

Related Questions