Home > OS >  Running into the problem of the UI not stretching out to the whole phone Despite being constrained a
Running into the problem of the UI not stretching out to the whole phone Despite being constrained a

Time:12-07

I'm trying to create a ui and running into the problem of the UI not stretching out at the top. Even after I have constrained all the elements and have disabled the action bar. Desired UI created inside android studio Android Manifest where I disabled the action bar and the UI inside the Virtual Device How do I remove that slightly gray bar at the top and have it be the color of the app itself ?

Any help will be really appreciated.

CodePudding user response:

you can use Theme.MaterialComponents.Light.NoActionBar.Bridge theme on both light and dark themes in android studio now it has two themes for light and dark mode based on user mode so use the above theme on both if you want to make status bar transparent you can use the following snippet

window.apply {
            clearFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS)
            addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS)
            if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
                decorView.systemUiVisibility =
                    View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN or View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR
            } else {
                decorView.systemUiVisibility = View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN
            }
            statusBarColor = ContextCompat.getColor(context,android.R.color.transparent)
        }

window is the one you get from the activity

  • Related