I have an activity consisting of the following elements:
<?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>
In my onResume
, I do the following:
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);
However, if the user swipes from the top edge of the screen to show the status bar and the notifications, the status bar won't go away, not even when tapped inside the web view. What am I doing wrong? Has been observed (not exclusively) on Android 7 and 8.
The theme is set to android:theme="@style/AppTheme.NoActionBar"
, compileSdkVersion
is 26.