Primary Dark Color Android Under API 21
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 -->
<color name="primaryDark">#800000</color>
<color name="light">#800080</color>
<color name="accent">#FF0000</color>
res/values-v21/colors.xml
:
<!-- Colours for API 21+ -->
<color name="primaryDark">#000008</color>
<color name="light">#080008</color>
<color name="accent">#0000FF</color>
Solution 2:
try set background programatically:
actionBar.setBackgroundDrawable(getResources().getDrawable(R.drawable.actionbar_background));
actionbar_background.xml
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<item>
<shape android:shape="rectangle">
<solid android:color="#e59300" />
</shape>
</item>
<item android:bottom="3dp">
<shape>
<solid android: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"