tools:context

经常在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

[html]  view plain copy
  1. <Button  
  2.     android:id="@+id/set_password"  
  3.     android:layout_width="wrap_content"  
  4.     android:layout_height="wrap_content"  
  5.     android_layout_gravity="east|center_vertical"  
  6.     android:text="@string/set_password">  
  7. </Button>  

 

执行Android-Lint就会报MissingPrefix警告:

Android-Lint Issue MissingPrefix 


1.2 解决XML中的问题

 

可以在Lint Warnings View中解决(图中图标从左至右顺序)

 

 Android-Lint ignore this Suppress this error with an annotation/attribute

点击该图标之后,直接更改了device_admin_sample.xml文件:

[html]  view plain copy
  1. <Button  
  2.     android:id="@+id/set_password"  
  3.     android:layout_width="wrap_content"  
  4.     android:layout_height="wrap_content"  
  5.     android_layout_gravity="east|center_vertical"  
  6.     android:text="@string/set_password"  
  7.     tools:ignore="MissingPrefix" >  
  8. </Button>  

XML文件中直接增加了tools:ignore="MissingPrefix"

 

 Android-Lint ignore file Ignore in this file

在本文件中忽略,而在别的文件中仍然出现。

 

 Android-Lint ignore project Ignore in this project

当前项目中都忽略该Issue。

执行之后,在本项目根目录下创建了lint.xml的文件,内容为:

[html]  view plain copy
  1. <?xml version="1.0"encoding="UTF-8"?>  
  2. <lint>  
  3.     <issue id="MissingPrefix"severity="ignore" />  
  4. </lint>  

 

 Android-Lint ignore all Always ignore

所有项目中都忽略。

 

[TIPS#1]  Android-Lint ignore project Ignore in this project和 Android-Lint ignore all Always ignore操作,同执行Lint Warnings View中的最后一个Icon -- Android-Lint Options Options…,然后配置某一个项目或者全局设置中该Issue的Severity为ignore。

[TIPS#2] Eclipse中的实现有BUG,有时设置了这些Ignore操作,即便立即执行检查也不一定生效,需要重启Eclipse。

 

引用来源地址.


  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值