13

我刚刚更新了我的 SDK,现在 eclipse 在我的 xml 中给了我各种完全不需要的警告......例如,我有一个没有 id 或背景的 RelativeLayout(它实际上是一个透明按钮)和eclipse 警告我这是一个无用的元素。有没有办法关闭这种白痴?

TIA

4

2 回答 2

13

根据http://tools.android.com/recent/ignoringlintwarnings上的文档,您可以通过包含工具 xmlns 来执行此操作:

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

然后在相关元素中添加 tools:ignore 注释:

<RelativeLayout
    tools:ignore="UselessParent"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:layout_margin="30dp"
    android:layout_centerInParent="true">
于 2014-05-07T16:06:03.757 回答
8

在 Eclipse ADT 插件的新更新中,将为您提供名称为 Lint 的新工具,这是该工具的一个 SO 链接,它的优点。点击这里

现在对于来自 Lint Android 工具的禁用 xml 警告,你需要去

Window-->Preferences-->Android-->Lint 错误检查

在此对话框中,您将找到 android 中 Xml 的所有问题,如果您想禁用它,您可以禁用它。并且确保您不会禁用有用的 lint 警告,因为它有助于我们找到在 xml 和很多中分配的多个 ID更多的..

于 2012-04-06T04:51:05.503 回答