Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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.

like image 783
Zaeem Sattar Avatar asked Mar 23 '17 18:03

Zaeem Sattar


Video Answer


1 Answers

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

like image 170
azizbekian Avatar answered Oct 17 '22 08:10

azizbekian