我是否可以始终使用lint忽略NewApi而不是其他styles.xml文件? [英] Can I always use lint ignore NewApi instead of different styles.xml files?

查看:76
本文介绍了我是否可以始终使用lint忽略NewApi而不是其他styles.xml文件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有两个styles.xml,一个在值中,另一个在values-v21资源文件夹中.

I have two styles.xml, one in values another in values-v21 resource folders.

values/styles.xml的内容是:

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的内容是:

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>

我可以从值-v21中删除styles.xml文件,并使用皮棉工具添加v21专用项吗?像这样的ignore ="NewApi"属性:

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>

我可以这样做吗?

如果我总能做到这一点,那么拥有两个分离的style.xml文件又有什么意义呢?

And if I can always do that what is the point of having two separated style.xml files?

推荐答案

因为您的布局可能不同,或者基于Android api使用了不同的小部件.

Because you may have different layout, or use different widgets based on Android api.

某些人可能会出于隐瞒不兼容的小部件属性的考虑而阻止使用 tools:ignore ="NewApi" .

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?

这篇关于我是否可以始终使用lint忽略NewApi而不是其他styles.xml文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆