Reputation:
My understanding is that suppressing individual warnings can be done in XML by adding an ignore
property, e.g.
xmlns:tools="http://schemas.android.com/tools"
tools:ignore="SpUsage"
android:textSize="30dp"
This works fine when the text size is directly specified. But when I use a reference to a dimension, e.g.
android:textSize="@dimen/largeTextSize"
Lint produces a warning in spite of the ignore.
Let's assume that the given case is a justified exception, and that the guidance on generally preferring sp
dimensions over dp
for text is well understood and followed.
Because this is an exception I do not want to disable the warning globally. How can I do it locally?
Upvotes: 7
Views: 8146
Reputation: 147
Only that approach helped me: Specify lint checking preferences in the lint.xml file. Place it in the root directory of your Android project.
<?xml version="1.0" encoding="UTF-8"?>
<lint>
<issue id="SpUsage" severity="ignore" />
</lint>
More about lint config look at: https://developer.android.com/studio/write/lint#config
Upvotes: 0
Reputation: 152787
You need to add the suppression on the dimen
value resource:
<resources xmlns:tools="http://schemas.android.com/tools">
<dimen name="largeTextSize" tools:ignore="SpUsage">123dp</dimen>
</resources>
Upvotes: 11