Fullscreen Mode Android Studio black stripe at the top

Viewed 1100

I want to do full screen in the app I did it with this code

`private fun hideSystemUI() {
    window.decorView.systemUiVisibility = (View.SYSTEM_UI_FLAG_IMMERSIVE
            or View.SYSTEM_UI_FLAG_LAYOUT_STABLE
            or View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION
            or View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN
            or View.SYSTEM_UI_FLAG_HIDE_NAVIGATION
            or View.SYSTEM_UI_FLAG_FULLSCREEN)
}
private fun showSystemUI() {
    window.decorView.systemUiVisibility = (View.SYSTEM_UI_FLAG_LAYOUT_STABLE
            or View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION
            or View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN)`

But I have a camera on the screen and I see a black bar. How to stretch the screen so that this bar is not there

Kotlin programming language Thank You Very Much

3 Answers

this problem happen with me for 2 different devices and this because of the front camera notch or screen cutout.

I used this code in oncreate() :

hideSystemUI();
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.P) { 
getWindow().getAttributes().layoutInDisplayCutoutMode = 
WindowManager.LayoutParams.LAYOUT_IN_DISPLAY_CUTOUT_MODE_SHORT_EDGES; }

Or in the theme style xml file add this line :

<item name="android:windowLayoutInDisplayCutoutMode">shortEdges</item> 

Go into the theme file and change your theme to "Theme.MaterialComponents.Light.NoActionBar

Use

requestWindowFeature(Window.FEATURE_NO_TITLE);//will hide the title   
getSupportActionBar().hide(); 
Related