I know that you can change the status bar color in Android's themes.xml file with the following line:
<item name="android:statusBarColor" tools:targetApi="l">@color/teal_200</item>
That being said, if I want to customize the color (ie. make it a hex value), how can I do this?
CodePudding user response:
You can define your own custom colors in a colors.xml
file in your res/values directory.
In colors.xml
you can do something like the following with your preferred hex value:
<?xml version="1.0" encoding="utf-8"?>
<resources>
<color name="custom_color">#FF3A52B2</color>
</resources>
And in your themes.xml
file you can then reference that custom color as follows:
<item name="android:statusBarColor" tools:targetApi="l">@color/custom_color</item>
CodePudding user response:
Place this is your values-v21/styles.xml, to enable this on Lollipop:
<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">@color/color_primary</item>
</style>
``