码迷,mamicode.com
首页 > 其他好文 > 详细

tools:context=".MainActivity的作用 (转载)

时间:2015-02-13 19:53:17      阅读:168      评论:0      收藏:0      [点我收藏+]

标签:

转自:http://blog.csdn.net/caiwenfeng_for_23/article/details/8373569

 

<TextView  
        android:layout_width="wrap_content"  
        android:layout_height="wrap_content"  
        android:layout_centerHorizontal="true"  
        android:layout_centerVertical="true"  
        android:text="@string/hello_world"  
        tools:context=".MainActivity" /> 

一直对于 tools:context=".MainActivity"这句不懂,今天查了下,发现是这样的:

 

tools:context="activity name"这一句不会被打包进APK。只是ADT的Layout Editor在你当前的Layout文件里面设置对应的渲染上下文,说明你当前的Layout所在的渲染上下文是activity name对应的那个activity,如果这个activity在manifest文件中设置了Theme,那么ADT的Layout Editor会根据这个Theme来渲染你当前的Layout。就是说如果你设置的MainActivity设置了一个Theme.Light(其他的也 可以),那么你在可视化布局管理器里面看到的背景阿控件阿什么的就应该是Theme.Light的样子。仅用于给你看所见即所得的效果而已。

 

tools:context=".MainActivity的作用 (转载)

标签:

原文地址:http://www.cnblogs.com/lance-ehf/p/4290741.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!