tools:context=”.MainActivity”与xmlns:tools名字空间
来源:互联网 发布:中邮网络培训学院 app 编辑:程序博客网 时间:2024/05/16 01:16
无意中发现默认的布局文件有些不同,LinearLayout变成了RelativeLayout,而且还有2段陌生的代码
xmlns:tools="http://schemas.android.com/tools"tools:context=".MainActivity"这是ADT20.0之后的变化,默认布局文件为:
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" android:paddingLeft="@dimen/activity_horizontal_margin" android:paddingRight="@dimen/activity_horizontal_margin" android:paddingTop="@dimen/activity_vertical_margin" android:paddingBottom="@dimen/activity_vertical_margin" tools:context=".MainActivity"> <TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="@string/hello_world" /></RelativeLayout>
还多了个新的namespace和相应的属性,这个属性的作用是什么呢?解释如下:
请各自选择相应语种,对号入座,O(∩_∩)O~
English Original Explaination:
One more thing: The "tools" namespace is special. The android packaging tool knows to ignore it, so none of those attributes will be packaged into the APK. We're using it for extra metadata in the layout. It's also where for example the attributes to suppress lint warnings are stored -- as tools:ignore.中文版意译:
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的样子。
仅用于给你看所见即所得的效果而已。
转自:http://www.mythroad.net/2013/01/08/toolscontext-mainactivity%E4%B8%8Exmlnstools%E5%90%8D%E5%AD%97%E7%A9%BA%E9%97%B4/
- tools:context=”.MainActivity”与xmlns:tools名字空间
- tools:context=”.MainActivity”与xmlns:tools名字空间
- xmlns:tools与tools:context
- xmlns:tools与tools:context
- tools:context=".MainActivity"
- tools:context=".MainActivity"
- tools:context与xmlns:tools学习笔记
- tools:context=".MainActivity的作用
- tools:context=".MainActivity的作用
- tools:context=".MainActivity的作用
- android--tools:context=".MainActivity的作用
- tools:context=".MainActivity的作用
- tools:context=".MainActivity的作用
- tools:context=".MainActivity的作用
- tools:context=".MainActivity的作用
- tools:context=".MainActivity的作用
- Android tools:context=".MainActivity的作用
- tools:context=".MainActivity的作用
- android 按返回键退出程序
- Objective-C语法之代码块(block)的使用
- struts2配置文件模板详细说明
- Flex addPopUp
- c#截取字符串
- tools:context=”.MainActivity”与xmlns:tools名字空间
- __autoload函数
- 在eclipse下手动建一个web项目
- wchar_t转char wchar_t*转char*
- EAS BOS 控制界面控件状态
- 计算机的族谱
- 基于 Jenkins 快速搭建持续集成环境
- QR码原理
- STL线程库简介