简体   繁体   中英

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.

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
        }

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM