问题
How can achieve full screen mode with Samsung Galaxy S10 and S10+, the following code do not work for me:
getWindow().getDecorView().setSystemUiVisibility(
// Set the content to appear under the system bars so that the
// content doesn't resize when the system bars hide and show.
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
| View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY
);
It hide the content of the status bar but it doesn't hide the status bar it self :(
Please help
回答1:
Put in the style of your app the following fixed this issue for me:
<item name="android:windowLayoutInDisplayCutoutMode">shortEdges</item>
For more details about supporting cutout look at this:
https://developer.android.com/guide/topics/display-cutout
回答2:
Try to create a style:
<style
name="Theme.AppCompat.Light.NoActionBar.FullScreen"
parent="@style/Theme.AppCompat.Light.NoActionBar">
<item name="android:windowNoTitle">true</item>
<item name="android:windowActionBar">false</item>
<item name="android:windowFullscreen">true</item>
<item name="android:windowContentOverlay">@null</item>
</style>
and then apply the theme to your activity:
<activity
android:name=".MyActivity"
android:theme="@style/Theme.AppCompat.Light.NoActionBar.FullScreen"
/>
UPDATE:
AFAIK, Samsung S10 has an aspect ratio of 19:9 (equivalent to 2.1)
So, in your manifest, add this tag on your <application>
<meta-data android:name="android.max_aspect" android:value="2.1" />
You can also try to set the resizeableActivity for Activity or Application:
android:resizeableActivity="true"
回答3:
From docs linked by Mohamad Bdour:
Note that Android might not allow the content view to overlap the system bars. To override this behavior and force content to extend into the cutout area, apply any of the following flags to the view visibility via the View.setSystemUiVisibility(int) method:
SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION SYSTEM_UI_FLAG_LAYOUT_STABLE
来源:https://stackoverflow.com/questions/55130940/galaxy-s10-s10-full-screen-mode