jaredrummler / Cyanea

A theme engine for Android
Apache License 2.0
1.45k stars 144 forks source link

Custom Status Bar Color #74

Closed ItsAnubhav closed 1 year ago

ItsAnubhav commented 4 years ago

I want the status bar colour to match the Toolbar colour. How can I achieve that ? Is there any API for that or do I have to edit the plugin ?

DatL4g commented 4 years ago

I did that using Kotlin:

//Your statusBarColor method
//depends if you doing this in Activity or Fragment
fun Fragment.statusBarColor(@ColorInt color: Int) {
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
        activity?.window?.addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS)
        activity?.window?.statusBarColor = color
    }
}

And calling in Fragment or Activity:

statusBarColor(Cyanea.instance.primary)