1

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?

Christian
  • 25,249
  • 40
  • 134
  • 225
  • Have u check this : https://stackoverflow.com/questions/43511326/android-making-activity-full-screen-with-status-bar-on-top-of-it – AskNilesh Aug 14 '19 at 09:10

1 Answers1

2

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>
Lakhwinder Singh
  • 6,799
  • 4
  • 25
  • 42