Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android: Make Actionbar overlap Activity layout

I have an activity where the Actionbar is hidden and when I click a button I want it to be visible, but I don't want the layout activity to scroll down, the bar must overlap it. How can I do such a thing?

To hide the bar i use

actionbar.hide();
getWindow().getDecorView().setSystemUiVisibility(View.SYSTEM_UI_FLAG_LOW_PROFILE);

And to make it visible:

actionbar.show();
getWindow().getDecorView().setSystemUiVisibility(View.SYSTEM_UI_FLAG_VISIBLE);

My layout is just

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    >

    <MyPager
        xmlns:android="http://schemas.android.com/apk/res/android"
        android:id="@+id/pager"
        android:layout_width="match_parent"
        android:layout_height="match_parent" >
    <MyPager>

</RelativeLayout>

Thanks in advance.

like image 576
e_ori Avatar asked Jan 11 '13 15:01

e_ori


1 Answers

You are probably looking for the ActionBar overlay mode. Enable it for a single Activity by calling requestWindowFeature(Window.FEATURE_ACTION_BAR_OVERLAY); before setContentView(). Or in a theme by setting android:windowActionBarOverlay to true.

like image 175
Matthias Robbers Avatar answered Nov 10 '22 14:11

Matthias Robbers