Suppress lint warning on view level

Boris Strandjev

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?

laalto

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

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

Suppress lint warning on view level

From Dev

Android Studio: suppress lint warning for if statement

From Dev

How to suppress Android Lint warning in Gradle script

From Dev

Suppress API level warning in code

From Dev

How to suppress MaxPermSize warning?

From Dev

How to suppress Scalastyle warning?

From Dev

Suppress Swift compiler warning

From Dev

How to suppress matplotlib warning?

From Dev

suppress warning messages in gnupg

From Dev

Android Studio Lint - set API level for lint

From Dev

Activity not registered in the manifest Lint warning

From Dev

Lint Warning: #647: Suspicious truncation

From Dev

How to suppress a specific warning in Swift

From Dev

Suppress Gradle Warning in Android Studio?

From Dev

kotlin suppress warning deprecated for Android

From Dev

Suppress 'Warning: no access to tty' in ssh

From Dev

Suppress warning:deleting 'void*' is undefined

From Dev

msvc precompiled header warning suppress

From Dev

Suppress “Ambiguous class resolution” warning

From Dev

Suppress rsOverlappingReportItems warning in RDLC files

From Dev

Suppress specific MySQL warning message

From Dev

Is this a real warning or an over-sensitive lint?

From Dev

Incorrect Android Lint warning on Unused Resources

From Dev

How to fix Unprotected SMS BroadcastReceiver lint warning

From Dev

Android lint SharedPreferences.Editor.apply() warning

From Dev

Android Lint: How to suppress all warnings associated with support library?

From Dev

How to suppress lint on specific line/string in resources xml files?

From Dev

How to suppress lint on specific line/string in resources xml files?

From Dev

How to suppress unchecked typecast warning with generics not at declaration?

Related Related

HotTag

Archive