Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Actionbar overlay not working as expected

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

/value-11/styles.xml

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

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

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?

like image 255
kelunik Avatar asked Sep 08 '13 13:09

kelunik


1 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:id="@+id/presentation"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:layout_gravity="center"
    android:contentDescription="@string/presentation"
    android:scaleType="fitCenter"
    android:fitsSystemWindows="true" >
</ImageView>

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. ;)

like image 68
kelunik Avatar answered Nov 15 '22 12:11

kelunik