How to change android status bar color to white and status bar icon color to grey

拜拜、爱过 提交于 2019-12-10 14:11:55

问题


i am trying to change color of my status bar to white with grey icons. i have tried almost every code solution for this problem but non of them worked for me.

i am using this java fucntion to change it and i am also posting my style(21) code.

public static void statusBarColor(Window window, Context ctx) {
            if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
                //Window window = getActivity().getWindow();

                window.addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS);
                window.clearFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);
                window.setStatusBarColor(ctx.getResources().getColor(R.color.statusbar_color));
            }
        }

this is my java code but its not working after thousand tries. and below is my style.xml (21)

 <style name="AppTheme.NoActionBar">
        <item name="windowActionBar">false</item>
        <item name="windowNoTitle">true</item>
        <item name="android:windowDrawsSystemBarBackgrounds">true</item>
        <item name="android:statusBarColor">@android:color/transparent</item>
        <item name="android:windowLightStatusBar" tools:targetApi="23">true</item>   
    </style>

if you think its duplicate of some other question then i should let you now i have tried 3,4 pages of google search and also implemented them.


回答1:


It is achievable with this flag:

<item name="android:windowLightStatusBar">true</item>

Unfortunately it's available from API 23 upwards, so you have to specify it in values-v23/styles.xml. See this for more info.

There is not any backport of this functionality, therefore it won't work on any lower 23 at the time of writing this.



来源:https://stackoverflow.com/questions/42984357/how-to-change-android-status-bar-color-to-white-and-status-bar-icon-color-to-gre

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!