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.
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.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With