White navigationbar with grey icons
Asked Answered
K

2

6

How can I get this style in my android app? White navigationbar and grey icons. An example is when opening the application drawer. enter image description here

I have tried many options but without success. the application minSdkVersion is 21, lollipop.

I have seen this solution, but I have not managed to apply it:

Status bar turns white and does not show content behind it

Kling answered 13/3, 2018 at 11:21 Comment(0)
Y
11

For API >= 23

Try :

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

OR in style :

<item name="android:windowLightStatusBar">true</item>
<item name="colorPrimary">@color/colorWhite</item>
<item name="colorPrimaryDark">#colorPrimaryDak</item>
<item name="colorAccent">@color/colorAccent</item>

For API < 23

Declare this under v21/style.

<item name="colorPrimaryDark" tools:targetApi="23">@color/colorPrimary</item> // white
<item name="android:windowLightStatusBar" tools:targetApi="23">true</item>

UPDATE :

<item name="colorPrimaryDark">@color/colorPrimary</item> // white
<item name="android:windowLightStatusBar" tools:targetApi="23">true</item>
Yeanling answered 13/3, 2018 at 11:36 Comment(21)
Thanks, but this solution require min sdk 23, right?Kling
21, I mention it above. it does not seem to work, the notificationbar turns gray, but not white :(Kling
@Kling Happy to help :) happy coding :)Yeanling
What is tools:targetApi="23" indicates in under v21? I guess, colorPrimaryDark is from support library.Buckjump
@Wizard It is defining target api as 23 so that the changes that applied on above 23 can be applied on below that also. yes colorPrimaryDark is from support library but we can define new values in theme for itYeanling
Okay so, There is no need to write tools:targetApi="23" in colorPrimaryDark as it is available for lower version too. For android:windowLightStatusBar it is good.Buckjump
@Wizard Ok i understood. i will try it out. thank you so much :)Yeanling
@Wizard No wait In api below 23 like in kitkat colorprimarydark is always black. so i need to declare it white for api below 23. whatever the color is it will show black in that. If you noticed.Yeanling
Yeah, but system will skip that for lower versions.Buckjump
@Wizard Don't know about it. I will check. Thank you :)Yeanling
Let us continue this discussion in chat.Buckjump
<item name="android:windowLightStatusBar">true</item> works for meSiderosis
@Siderosis Happy to help :) Happy coding :)Yeanling
this solution will not work for devices less than 23Cotto
@AbdelrhmanTalat It will work. add lines below API < 23 in answer. also add that style in v21/style. let me know if you face any issue in this or any error logsYeanling
it doesn't work because your code only targets tools:targetApi = 23Cotto
I did and it doesn't, can u explain why would it work?Cotto
I do not understand who is voting for this answer. This solution may not work for versions 21-22 APIJacquesjacquet
I don't get why you answered and why people keep upvoting. OP asked specifically for API < 23 and said it is not working and you posted answer that only suppresses the warning that is it.Aracelis
Hi @Aracelis not sure but this solution always works for me. might be your project theme is different maybe that may cause conflict.Yeanling
So you get dark colored status bar icons? Can you please screenshot any of your app on API < 23 and prove that it really works?Aracelis
C
1

You just can't. It's not provided for API 21-22 it's.

However you can make it black:

getWindow().setStatusBarColor(Color.BLACK);

Full Example:

public class MainActivity extends AppCompatActivity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main_activity);

        if (Build.VERSION.SDK_INT < Build.VERSION_CODES.M) {
            getWindow().setStatusBarColor(Color.BLACK);
        }

    }
}
Cynth answered 6/6, 2022 at 10:10 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.