Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Suppressing Lint Warnings in XML

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?

like image 450
jerry Avatar asked Aug 17 '16 14:08

jerry


1 Answers

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>
like image 91
laalto Avatar answered Sep 22 '22 13:09

laalto