Android 如何使工具栏覆盖和沉浸?
我想让我的应用程序沉浸其中,就像下面这个阅读器应用程序一样,但它不能像我想要的那样工作,有人能给我一个想法吗 正常的 正常时,工具栏和状态将隐藏 拉状态 拉动状态时,将显示状态。 点击内容 在内容中单击时,状态和工具栏都会显示精美的动画。 这是我的密码Android 如何使工具栏覆盖和沉浸?,android,android-actionbar,material-design,toolbar,android-immersive,Android,Android Actionbar,Material Design,Toolbar,Android Immersive,我想让我的应用程序沉浸其中,就像下面这个阅读器应用程序一样,但它不能像我想要的那样工作,有人能给我一个想法吗 正常的 正常时,工具栏和状态将隐藏 拉状态 拉动状态时,将显示状态。 点击内容 在内容中单击时,状态和工具栏都会显示精美的动画。 这是我的密码 private void hideStatus() { getWindow().getDecorView().setSystemUiVisibility( View.SYSTEM_UI_FLAG_LAYOUT_
private void hideStatus() {
getWindow().getDecorView().setSystemUiVisibility(
View.SYSTEM_UI_FLAG_LAYOUT_STABLE
| View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION
| View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN
| View.SYSTEM_UI_FLAG_HIDE_NAVIGATION
| View.SYSTEM_UI_FLAG_FULLSCREEN
| View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY);
getSupportActionBar().hide();
}
并使用handler.sendEmptyMessageDelayed()
进行延迟。但它与任何动画一起工作。
然后我添加了true
,但不起作用
这是我的布局代码
<android.support.design.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/ctl_indoor"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true">
<LinearLayout
android:id="@+id/ll_indoor"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true"
android:orientation="vertical">
</LinearLayout>
<android.support.design.widget.AppBarLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<android.support.v7.widget.Toolbar
android:id="@+id/tool_bar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
android:background="?attr/colorPrimary"
app:popupTheme="@style/ThemeOverlay.AppCompat.Light"
app:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar" />
</android.support.design.widget.AppBarLayout>
</android.support.design.widget.CoordinatorLayout>
对不起,我的英语不好
android:fitsSystemWindows="true"
放进你的布局中
<LinearLayout
xmlns:tools="http://schemas.android.com/tools"
xmlns:android="http://schemas.android.com/apk/res/android"
tools:context=".LauncherActivity"
android:fitsSystemWindows="true"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent" >
使用CoordinatorLayout谢谢,但我只是使用CoordinatorLayout。我认为您需要指定滚动行为,您必须实现一个抽象类谢谢,但它仍然不起作用,bool栏仍然存在。