How to change the status bar color in Android?

后端 未结 21 1892
旧时难觅i
旧时难觅i 2020-11-21 16:09

First of all it\'s not a duplicate as in How to change the background color of android status bar

How do I change the status bar color which should be same as in nav

相关标签:
21条回答
  • 2020-11-21 16:42

    change the colorPrimaryDark to your desire color into the res/values/styles.xml file

        <resources>
            <color name="colorPrimary">#800000</color>
            <color name="colorPrimaryDark">#303F9F</color> //This Line
            <color name="colorAccent">#FF4081</color>
            <color name="red">#FF0000</color>
            <color name="white">#FFFFFF</color>
           <color name="cream">#fffdd0</color>
           <color name="burgundy">#800000</color>
        </resources>
    
    0 讨论(0)
  • 2020-11-21 16:46

    To Change the color of the status bar go to res/values-v21/styles.xml and color of status bar

    <resources>
        <!-- Base application theme. -->
        <style name="AppTheme" parent="Theme.AppCompat.Light">
            <item name="colorPrimary">@color/color_primary</item>
            <item name="colorPrimaryDark">@color/color_secondary</item>
            <item name="colorAccent">@color/color_accent</item>
            <item name="android:statusBarColor">#0000FF</item>
        </style>
    </resources>
    
    0 讨论(0)
  • 2020-11-21 16:46

    One more solution:

    final View decorView = w.getDecorView();
    View view = new View(BaseControllerActivity.this);
    final int statusBarHeight = UiUtil.getStatusBarHeight(ContextHolder.get());
    view.setLayoutParams(new FrameLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, statusBarHeight));
    view.setBackgroundColor(colorValue);
    ((ViewGroup)decorView).addView(view);
    
    0 讨论(0)
提交回复
热议问题