Android:使Actionbar重叠活动布局

e_o*_*ori 8 android android-activity android-actionbar

我有一个隐藏Actionbar的活动,当我点击一个按钮时我希望它可见,但我不希望布局活动向下滚动,栏必须重叠它.我该怎么办?

隐藏我使用的栏

actionbar.hide();
getWindow().getDecorView().setSystemUiVisibility(View.SYSTEM_UI_FLAG_LOW_PROFILE);
Run Code Online (Sandbox Code Playgroud)

并使其可见:

actionbar.show();
getWindow().getDecorView().setSystemUiVisibility(View.SYSTEM_UI_FLAG_VISIBLE);
Run Code Online (Sandbox Code Playgroud)

我的布局是公正的

<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>
Run Code Online (Sandbox Code Playgroud)

提前致谢.

Mat*_*ers 30

您可能正在寻找ActionBar叠加模式.Activity通过requestWindowFeature(Window.FEATURE_ACTION_BAR_OVERLAY);之前的呼叫启用它setContentView().或者通过设置android:windowActionBarOverlay为主题true.

  • 就我而言,我还必须在“super.onCreate(savedInstanceState);”之前放置“requestWindowFeature(Window.FEATURE_ACTION_BAR_OVERLAY);” (2认同)