How do I suppress the warnings about me using px in a layout xml?
Asked Answered
T

1

7

I am working with a project that includes a Sony SmartWatch and when I send layouts to that I need to use real pixel values. [If you haven't used on its a watch that is connected via bluetooth and works as an extra display the "controlling" device can draw to]

I am using Eclipse so it gives me a warning that I should not use px in a layout.xml file ... is there a way to suppress these warnings for the lines where I know I should use px? (note: I want to suppress these warnings only on the lines where I know it should be used, so turning of this check from the lint error checker is not what I want)

And again, I know that px is generally a bad idea when working with android, but this is one of the few cases where it is needed.

Tremann answered 4/5, 2012 at 8:23 Comment(0)
C
11

Add the xmlns:tools="http://schemas.android.com/tools" to your xml, then you can disable the px-warnings by including this in your view: tools:ignore="PxUsage".

This can be done automatically from the lint-warnings window by clicking on the "Suppress this error with an annotation/attribute" button.

Couplet answered 4/5, 2012 at 8:28 Comment(1)
Similarly, for anyone else wondering, you can ignore warnings for using dp in android:textSize with tools:ignore="spUsage".Apprehensive

© 2022 - 2024 — McMap. All rights reserved.