tools:context=".MainActivity的作用
2016-02-23 10:06
411 查看
[html] view
plaincopyprint?
<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" />
[html] view
plaincopyprint?
<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的样子。仅用于给你看所见即所得的效果而已。
plaincopyprint?
<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" />
[html] view
plaincopyprint?
<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的样子。仅用于给你看所见即所得的效果而已。
相关文章推荐
- poj2010 Moo University - Financial Aid
- VS2008启动时提示“Package load failure”
- waiting for X server to shut down Server terminated successfully(0) ,closing log file
- AIDL service纪事 注意事项
- 人工智能 有限状态机 的时代过去了
- could not obtain the localhost address
- Rails 中的事物处理
- Maven-010-maven 编译报错:Failure to ... in ... was cached in the local repository, resolution will not be reattempted until the update interval of nexus has elapsed or updates are forced.
- 可执行程序的入口点在那里?(强化概念:程序真正的入口是mainCRTstartup)
- Educational Codeforces Round 8 F. Bear and Fair Set(最大流 | Hall定理)
- POJ1704--Georgia and Bob--staircase nim
- CodeForces 50B Choosing Symbol Pairs
- Event Pairs
- RAID在企业服务器中的应用(RAID几种级别)
- Class类文件结构浅析 http://blog.csdn.net/kobejayandy/article/details/39620833
- Aizu 2305
- A. Again Twenty Five!
- MTK MAINAF-->2-000c
- 贪吃蛇的实现及其简单AI设计
- Jenkins进阶系列之——03parameterized-trigger插件