有没有办法禁用xml警告?

时间:2012-04-06 04:08:40

标签: android eclipse

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

TIA

2 个答案:

答案 0 :(得分:13)

根据http://tools.android.com/recent/ignoringlintwarnings的文档,您可以通过包含工具xmlns:

来实现此目的
xmlns:tools="http://schemas.android.com/tools"

然后添加工具:忽略相关元素中的注释:

<RelativeLayout
    tools:ignore="UselessParent"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:layout_margin="30dp"
    android:layout_centerInParent="true">

答案 1 :(得分:8)

在Eclipse的新更新中,ADT插件将为您提供新工具,此名称是Lint,这是此工具的一个SO链接,它具有优势。Click Here

现在,对于来自Lint Android Tool的禁用xml警告,您需要转到

窗口 - &gt;首选项 - &gt; Android - &gt; Lint错误检查

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

相关问题