I have two styles.xml, one in values another in values-v21 resource folders.
values/styles.xml content is:
<resources>
<style name="AppTheme.NoActionBar">
<item name="windowActionBar">false</item>
<item name="windowNoTitle">true</item>
</style>
</resources>
values-v21/styles.xml content is:
<resources>
<style name="AppTheme.NoActionBar">
<item name="windowActionBar">false</item>
<item name="windowNoTitle">true</item>
<item name="android:windowDrawsSystemBarBackgrounds">true</item>
<item name="android:statusBarColor">@android:color/transparent</item>
</style>
</resources>
Can I delete styles.xml file from values-v21 and add v21dedicated items with a lint tools: ignore="NewApi" property like this:
<resources xmlns:tools="http://schemas.android.com/tools">
<style name="AppTheme.NoActionBar">
<item name="windowActionBar">false</item>
<item name="windowNoTitle">true</item>
<item name="android:windowDrawsSystemBarBackgrounds" tools:ignore="NewApi">true</item>
<item name="android:statusBarColor" tools:ignore="NewApi">@android:color/transparent</item>
</style>
</resources>
Can I do that without any problem?
And if I can always do that what is the point of having two separated style.xml files?
Because you may have different layout, or use different widgets based on Android api.
Some folks may discourage the use of tools:ignore="NewApi"
, citing concerns of hiding incompatible widget attributes.
My opinion is - it depends. If it is a trivial matter, why would I have to maintain separate sets of files?
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With