Home » Android » android – Actionbar overlay not working as expected

android – Actionbar overlay not working as expected

Posted by: admin June 16, 2020 Leave a comment


My Android app has a translucent ActionBar. It hides when I touch the screen and shows up again when the screen is touched again.


<style name="FullscreenTheme" parent="android:Theme.Holo">
    <item name="android:actionBarStyle">@style/FullscreenActionBarStyle</item>
    <item name="android:windowActionBarOverlay">true</item>
    <item name="android:windowBackground">@null</item>
    <item name="buttonBarStyle">?android:attr/buttonBarStyle</item>
    <item name="buttonBarButtonStyle">?android:attr/buttonBarButtonStyle</item>

<style name="FullscreenActionBarStyle" parent="android:Widget.Holo.ActionBar">
    <item name="android:background">@color/black_overlay</item>

When I start the app, the ActionBar is translucent, that’s the expected state. When I hide it using getActionBar().hide(); and make it show up again using getActionBar().show(); it’s not translucent anymore.

It’s a Fragment in a ViewPager. If I just scroll right, hide and show works like expected: the ActionBar is translucent after show(); gets called.

Update: Everytime I scroll left, the bug is there again.

Has anybody an idea how to fix this, so it works also on the first page or when the user has scrolled one or more to the left?

How to&Answers:

I solved my problem:

The layout of the view inside the ViewPager was the following:

<ImageView xmlns:android="http://schemas.android.com/apk/res/android"
    android:fitsSystemWindows="true" >

android:fitsSystemWindows="true" was responsible for this weird bug, without this, all works fine.

And sorry for writing so less code, I just thought it was a javacode-issue and not related to the xml. And I could not find a codeblock, that approx. would be the one with the error in it. How should I, the error was in my layout-file. 😉