Android: Make Actionbar overlap Activity layout

15,570

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.

Share:
15,570
e_ori
Author by

e_ori

Updated on July 27, 2022

Comments

  • e_ori
    e_ori almost 2 years

    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.

  • e_ori
    e_ori over 11 years
    Excellent, just what I needed.
  • Soren Stoutner
    Soren Stoutner over 8 years
    In my case I also had to place requestWindowFeature(Window.FEATURE_ACTION_BAR_OVERLAY); before super.onCreate(savedInstanceState);