Issue
I want to accommodate for older Android versions (say 17 to 20) with specific style specs. So I made these:
- values/styles.xml (what I think should be the default)
- values-v17/styles.xml
- values-v18/styles.xml
- values-v19/styles.xml
- values-v20/styles.xml
In my values/styles.xml
file I keep the default for versions 21+. However, the style that's actually applied in both the preview and the virtual device is that of v20, for display versions 21 and up. If I erase values-v20/styles.xml
then it's the next one down the line, v19, that takes over. Why isn't the default style taking over?
Simple example:
values-v20/styles.xml:
<?xml version="1.0" encoding="utf-8"?>
<resources>
<style name="Button.AccentButton" parent="Theme.AppCompat">
<item name="android:textColor">@android:color/white</item>
<item name="android:background">@color/red</item>
</style>
</resources>
values/styles.xml
<?xml version="1.0" encoding="utf-8"?>
<resources>
<style name="Button.AccentButton" parent="Theme.AppCompat">
<item name="android:textColor">@android:color/white</item>
<item name="android:background">@color/green</item>
</style>
</resources>
Final result: v21+ button shows red, should be green.
Solution
It works the other way around!
- values/styles.xml (the default for all versions below lowest specified)
- values-v21/styles.xml (values for v21+)
In other words, the first versioned folder applies to all the following versions too. The un-versioned folder applies to versions below the lowest versioned folder.
Answered By - MPelletier
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.