Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can I always use lint ignore NewApi instead of different styles.xml files?

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?

like image 705
Mahpooya Avatar asked Feb 01 '17 12:02

Mahpooya


1 Answers

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?

like image 70
Jack Cheung Avatar answered Sep 19 '22 06:09

Jack Cheung