Skip to content Skip to sidebar Skip to footer

Primary Dark Color Android Under Api 21

i want to color the Statusbar, for a better look in Android 5.0. I want to set the three color primarydark,light and accent. But my minimum API is 15. Is there any chance just to u

Solution 1:

You can have different styles for different API levels.

For API < 21, you would use a normal res/values/styles.xml, and then for API 21+, you would have res/values-v21/styles.xml.

If the device is running API 21 or higher, then it will use the file in the -v21 folder. If you just want to set <color> values, then just name the keys the same and do the same with colors.xml.

http://developer.android.com/guide/topics/resources/providing-resources.html#AlternativeResources

Example:

res/values/colors.xml:

<!-- Colours for API <21 --><colorname="primaryDark">#800000</color><colorname="light">#800080</color><colorname="accent">#FF0000</color>

res/values-v21/colors.xml:

<!-- Colours for API 21+ --><colorname="primaryDark">#000008</color><colorname="light">#080008</color><colorname="accent">#0000FF</color>

Solution 2:

try set background programatically:

actionBar.setBackgroundDrawable(getResources().getDrawable(R.drawable.actionbar_background));


actionbar_background.xml

<layer-listxmlns:android="http://schemas.android.com/apk/res/android"><item><shapeandroid:shape="rectangle"><solidandroid:color="#e59300" /></shape></item><itemandroid:bottom="3dp"><shape><solidandroid:color="#fbb903" /></shape></item></layer-list>

Solution 3:

colorPrimaryDark is used to color the status bar...Status bar theme is a feature that was added to Android in Lollipop. Keep in mind that the status bar will be black on older devices (no matter what the theme specifies).

Referenced from 《Android Programming Guide 2ed》the big nerd ranch guide P360. But I cannot find it in android developer guide.

Post a Comment for "Primary Dark Color Android Under Api 21"