How can I make the status bar white with black icons?

前端 未结 7 783
野性不改
野性不改 2020-12-02 18:03

I want to change the colour of the status bar for my app so that it\'s white with black icons (instead of the default black with white icons). Is there any way of doing this

相关标签:
7条回答
  • 2020-12-02 18:24

    Just added to my activity on Kotlin:

    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
                    window.decorView.systemUiVisibility =View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR
                    window.statusBarColor = Color.WHITE
                }
    
    0 讨论(0)
  • 2020-12-02 18:25

    just add this to you style

    <item name="android:windowDrawsSystemBarBackgrounds">true</item>
    <item name="android:statusBarColor">@android:color/transparent</item>
    

    set android:windowDrawsSystemBarBackgrounds to true*. This is a flag whose description is given below:

    Flag indicating whether this Window is responsible for drawing the background for the system bars. If true and the window is not floating, the system bars are drawn with a transparent background and the corresponding areas in this window are filled with the colors specified in {@link android.R.attr#statusBarColor} and {@link android.R.attr#navigationBarColor}. Corresponds to {@link android.view.WindowManager.LayoutParams#FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS}.

    0 讨论(0)
  • 2020-12-02 18:32

    No such way to this unless if you have a control of the whole rom to customize that manually. What i suggest you to do is, use a light gray color for the status bar color through your theme like the google drive does.

    Edit: please refer to @Wrekcker answer as this changed in android M.

    0 讨论(0)
  • 2020-12-02 18:35

    It is possible to make the white status bar with grey icons e.g. this way for SDK >= 23 (see docs):

    <style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
        <item name="android:windowLightStatusBar">true</item>
    </style>
    

    in your styles.xml and set the colorPrimary to white or programmatically:

    getWindow().setStatusBarColor(Color.WHITE);
    
    0 讨论(0)
  • 2020-12-02 18:37

    You can use it this way in Kotlin

     window.decorView.systemUiVisibility = View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR
    

    Make sure to call it in onCreate() before setContentView()

    0 讨论(0)
  • 2020-12-02 18:39

    With Android M (api level 23) you can achieve this from theme with android:windowLightStatusBar attribute.

    Edit :

    Just as Pdroid mentioned, this can also be achieved programatically:

    getWindow().getDecorView().setSystemUiVisibility(View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR); 
    
    0 讨论(0)
提交回复
热议问题