I want to be able to control the background of the status bar and show a color gradient in it that seamless transitions into the area below the status bar.
Ideally, I would be able to control the fullscreen along with the area where the status bar is located and the status bar would be overlayed over the layout that I draw.
Is that possible in Android? If so, how do I have to set the styles.xml for it?
Try this
@RequiresApi(Build.VERSION_CODES.LOLLIPOP)
fun changeStatusBarColor() {
window.addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS)
window.statusBarColor = ContextCompat.getColor(this, android.R.color.transparent)
window.navigationBarColor = ContextCompat.getColor(this, android.R.color.transparent)
window.setBackgroundDrawableResource(R.drawable.drawable_gradient_theme)
}
drawable_gradient_theme
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android">
<gradient
android:angle="180"
android:endColor="#FF2080"
android:startColor="#FF8951" /><!--android:centerColor="#C12389"-->
</shape>