经常在Layout文件里面可以看到
tools:context="com.achep.header2actionbardemo.MainActivity"
tools:ignore="MergeRootFrame"
-------------------------------------------------------------------------------------------------------------------------------------
tools:context="activity name"
一般我们的布局后界面长什么样.程序就长什么样的.
而且,一般如果我们在代码里面修改了布局.把主题从Theme.Black 调为 Theme.Light .
打开 Layout.xml 文件是不会看到变化
除非app在手机运行时.
为了打破这个僵局..就需要到这句话了..他让这个View根据你给的这个Context.去查看对布局的改变.
动态的显示界面.给你看所见即所得的效果而已。(其他的也可以),
值得注意的是.这一句不会被打包进APK。
即只是ADT的Layout Editor在你当前的Layout文件里面设置对应的渲染上下文,
说明你当前的Layout所在的渲染上下文是activity name对应的那个activity,
如果这个activity在manifest文件中设置了Theme,那么ADT的Layout Editor会根据这个Theme来渲染你当前的Layout。
仅用于给你看所见即所得的效果而已。
-------------------------------------------------------------------------------------------------
tools:ignore="MergeRootFrame"
这句话是人如其名啊,他会忽略你给定的内容..如下.
忽略XML文件中的问题
1.1 MissingPrefix问题
Layout的device_admin_sample.xml文件中定义了下面的Button
- <Button
- android:id="@+id/set_password"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android_layout_gravity="east|center_vertical"
- android:text="@string/set_password">
- </Button>
执行Android-Lint就会报MissingPrefix警告:
1.2 解决XML中的问题
可以在Lint Warnings View中解决(图中图标从左至右顺序)
Suppress this error with an annotation/attribute
点击该图标之后,直接更改了device_admin_sample.xml文件:
- <Button
- android:id="@+id/set_password"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android_layout_gravity="east|center_vertical"
- android:text="@string/set_password"
- tools:ignore="MissingPrefix" >
- </Button>
XML文件中直接增加了tools:ignore="MissingPrefix"。
Ignore in this file
在本文件中忽略,而在别的文件中仍然出现。
Ignore in this project
当前项目中都忽略该Issue。
执行之后,在本项目根目录下创建了lint.xml的文件,内容为:
- <?xml version="1.0"encoding="UTF-8"?>
- <lint>
- <issue id="MissingPrefix"severity="ignore" />
- </lint>
Always ignore
所有项目中都忽略。
[TIPS#1] Ignore in this project和 Always ignore操作,同执行Lint Warnings View中的最后一个Icon -- Options…,然后配置某一个项目或者全局设置中该Issue的Severity为ignore。
[TIPS#2] Eclipse中的实现有BUG,有时设置了这些Ignore操作,即便立即执行检查也不一定生效,需要重启Eclipse。