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. 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