Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Suppress lint warning on view level

I am getting the following error from lint: InconsistentLayout. Sometimes this is expected as the tablet and phone layout differ. That's why the last couple sentences of the lint warning:

There are cases where this is intentional. For example, you may have a dedicated large tablet layout which adds some extra widgets that are not present in the phone version of the layout. As long as the code accessing the layout resource is careful to handle this properly, it is valid. In that case, you can suppress this lint check for the given extra or missing views, or the whole layout

Perfect, I agree. I want to suppress the warning, but only for the specific view I am getting it, not for the entire layout containing it (to avoid hiding unintentional errors). I am usaully configuring lint suppress warning in lint.xml file in my project that maven uses while building.

I suppress the warnigns on layout level like so:

<?xml version="1.0" encoding="UTF-8"?>
<lint>
    <issue id="InconsistentLayout" >

        <ignore path="res/layout/my_layout.xml" />
    </issue>
</lint>

How can I declare lint to ignore just the view id I verified is OK to be inconsistent?

like image 823
Boris Strandjev Avatar asked Sep 25 '13 11:09

Boris Strandjev


1 Answers

Add the following attribute to the view:

tools:ignore="InconsistentLayout"

and add the namespace prefix declaration

xmlns:tools="http://schemas.android.com/tools"

to the view element or one of its parents.

Further reading: http://developer.android.com/tools/debugging/improving-w-lint.html#src

like image 131
laalto Avatar answered Oct 10 '22 23:10

laalto