【发布时间】:2018-07-17 12:45:50
【问题描述】:
我根据Using Immersive Full-Screen Mode做了一个关于沉浸式全屏模式的简单项目
但首先,当我选择Make Immersive 按钮时,应用程序正在进入沉浸式全屏模式。
我的问题是在选择Cancel Immersive 按钮后,再次选择Make Immsersive。虽然app是沉浸模式,但是状态栏的地方是白色的
这是我的隐藏和显示功能
private void hideSystemUI() {
// Set the IMMERSIVE flag.
// Set the content to appear under the system bars so that the content
// doesn't resize when the system bars hide and show.
View mDecorView = getWindow().getDecorView();
mDecorView.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);
}
private void showSystemUI() {
View mDecorView = getWindow().getDecorView();
mDecorView.setSystemUiVisibility(
View.SYSTEM_UI_FLAG_LAYOUT_STABLE
|View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION
| View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN);
}
我的activity_main.xml 是
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent">
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context="com.example.aungmyolwin.immsersivedelete.MainActivity">
<Button
android:id="@+id/btn_immersive"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="make immersive" />
<Button
android:id="@+id/btn_cancel_immersive"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="cancle immersive" />
<Button
android:id="@+id/btn_show_dialog"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="show dialog" />
</LinearLayout>
</FrameLayout>
【问题讨论】:
标签: android android-theme android-fullscreen