我的活动包含以下元素:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout 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"
app:layout_behavior="@string/appbar_scrolling_view_behavior"
tools:showIn="@layout/activity_game"
android:keepScreenOn="true">
<SurfaceView
android:id="@+id/scan_surface"
android:layout_width="match_parent"
android:layout_height="300px"
android:layout_alignParentStart="true"
android:layout_alignParentTop="true">
</SurfaceView>
<TextView
android:id="@+id/qr_code_result"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="TextView" />
<WebView
android:id="@+id/webview"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_alignParentStart="true"
android:layout_alignParentTop="true"
android:visibility="visible" />
</RelativeLayout>
在我的onResume
中,我执行以下操作:
super.onResume();
View decorView = getWindow().getDecorView();
decorView.setSystemUiVisibility(
View.SYSTEM_UI_FLAG_IMMERSIVE
// Set the content to appear under the system bars so that the
// content doesn't resize when the system bars hide and show.
| View.SYSTEM_UI_FLAG_LAYOUT_STABLE
| View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION
| View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN
// Hide the nav bar and status bar
| View.SYSTEM_UI_FLAG_HIDE_NAVIGATION
| View.SYSTEM_UI_FLAG_FULLSCREEN);
但是,如果用户从屏幕的顶部边缘滑动以显示状态栏和通知,则即使在Web视图中点击状态栏也不会消失。我究竟做错了什么?已在Android 7和8上观察到(并非唯一)。
主题设置为android:theme="@style/AppTheme.NoActionBar"
,compileSdkVersion
为26。