Łukasz
Łukasz

Reputation: 71

Fullscreen Mode Android Studio black stripe at the top

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

Upvotes: 6

Views: 2374

Answers (3)

Mohamed Mohamedein
Mohamed Mohamedein

Reputation: 69

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> 

Upvotes: 5

Kamal Nayan
Kamal Nayan

Reputation: 1718

Use

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

Upvotes: 0

iamdhavalparmar
iamdhavalparmar

Reputation: 1218

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

Upvotes: 2

Related Questions