2016-08-17 72 views
1

我的理解是,通过添加一个ignore属性(例如,以XML格式取消皮棉警告

xmlns:tools="http://schemas.android.com/tools" 
tools:ignore="SpUsage" 
android:textSize="30dp" 

当直接指定文本大小时,这可以正常工作。但是,当我使用对维度的引用时,例如

android:textSize="@dimen/largeTextSize" 

尽管忽视Lint会产生警告。

让我们假设给定的情况是一个合理的例外,并且对文本的sp维度的覆盖范围通常优于dp的指导是很好的理解和遵循。

因为这是一个例外,我不想全局禁用警告。我怎样才能在本地做到这一点?

回答

4

您需要添加对dimen价值资源的抑制:

<resources xmlns:tools="http://schemas.android.com/tools"> 
    <dimen name="largeTextSize" tools:ignore="SpUsage">123dp</dimen> 
</resources> 
+0

辉煌!谢谢。 – jerry