user16365371
user16365371

Reputation: 11

Status bar icons are hiding with status bar white color in Android

I am using code snippet given below:

 <style name="AppTheme.NoActionBar.HomeScreen" parent="Theme.AppCompat.Light.NoActionBar">
            <item name="android:textViewStyle">@style/default_font</item>
            <item name="android:windowLightStatusBar">true</item>
            <item name="colorPrimaryDark">@android:color/white</item>
            <item name="colorAccent">@android:color/white</item> 

It changes the color of status bar to white, But not changing the icons(wifi, network etc) color to black.

I found a solution :

getWindow().getDecorView().setSystemUiVisibility(View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR);

But it is depreciated in android 11.

Could any one please help to change status bar color to white and icons to black programmatically.

Upvotes: 1

Views: 750

Answers (1)

Tippu Fisal Sheriff
Tippu Fisal Sheriff

Reputation: 2846

In Kotlin

requireActivity().window.apply {
            clearFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS)
            addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS)
            decorView.systemUiVisibility = View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR
            statusBarColor = Color.WHITE
        }

Upvotes: 1

Related Questions