How to change android status bar color to white and status bar icon color to grey
Asked Answered
S

1

7

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.

Sentinel answered 23/3, 2017 at 18:38 Comment(1)
Whats does your xml do as of now?Offing
B
7

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.

enter image description here

Bortman answered 24/3, 2017 at 6:1 Comment(2)
yes but the question is that how to implement same thing in lollipop. its very confusing tight nowSentinel
and upvote to question will also be highly appreciatable :)Sentinel

© 2022 - 2024 — McMap. All rights reserved.