我的理解是,可以通过添加ignore
属性(例如,在XML中)来抑制单个警告
xmlns:tools="http://schemas.android.com/tools"
tools:ignore="SpUsage"
android:textSize="30dp"
直接指定文本大小时,此方法效果很好。但是当我使用对尺寸的引用时,例如
android:textSize="@dimen/largeTextSize"
尽管忽略,棉绒仍会发出警告。
让我们假设给定的情况是有道理的例外,并且很好地理解和遵循sp
了有关通常首选dp
文本尺寸的指导。
因为这是一个例外,所以我不想全局禁用警告。如何在本地进行?
您需要在dimen
值资源上添加抑制:
<resources xmlns:tools="http://schemas.android.com/tools">
<dimen name="largeTextSize" tools:ignore="SpUsage">123dp</dimen>
</resources>
辉煌!谢谢。