【Android】安卓布局文件中xmlns属性
来源:互联网 发布:希色官方旗舰店 淘宝 编辑:程序博客网 时间:2024/05/16 16:04
定义及使用
xmlns是XML Namespaces的缩写,中文名称是XML(标准通用标记语言的子集)命名空间
自定义View的时候有时候会在布局文件中使用到
命名规则如下: xmlns:前缀=http://shemas.android.com/apk/res/应用程序包名
例如: xmlns:myview="http://schemas.android.com/apk/myview"
使用的时候按如下格式:
namespace-prefix(前缀):属性
例如: myview:attr
示例
如果使用xmlns,则xmlns的定义必须放在最外层开始的的标记中
当命名空间被定义之后,所有带有相同前缀的子元素都会与同一个命名空间相关联。避免XML解析器对xml解析时的发送名字冲突,这就是使用xmlns的必要性。当自定义的View有自己的属性的时候,就用到xmlns来定义一个命名空间
例如自定义的一个环形进度条属性的命名空间:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" xmlns:zp="http://schemas.android.com/apk/circlepb" android:layout_width="fill_parent" android:layout_height="fill_parent" > <com.zp.pbd.view.CircleWithNumber android:layout_width="200dp" android:layout_height="200dp" android:layout_marginLeft="50dp" android:layout_marginTop="50dip" android:padding="5dp" android:progress="70" zp:progress_reached_bar_height="20dp" zp:progress_text_color="#000000" zp:progress_unreached_color="#ffffff" /> </LinearLayout>
定义并使用了一个zp命名空间
0 0
- 【Android】安卓布局文件中xmlns属性
- Android布局文件中xml里的xmlns:的作用
- xmlns:android作用以及自定义布局属性
- xmlns:android作用以及自定义布局属性
- xmlns:android作用以及自定义布局属性
- xmlns:android作用以及自定义布局属性
- xmlns:android作用以及自定义布局属性
- android中xmlns:tools属性详解
- android中xmlns:tools属性详解
- android中xmlns:tools属性详解
- android中xmlns:tools属性详解
- android中xmlns:tools属性详解
- android中xmlns:tools属性详解
- android中xmlns:tools属性详解
- Android布局文件中的xmlns:tools作用以及用法
- Android布局文件中属性介绍
- Android布局文件中常用的属性
- android布局文件中一些属性介绍
- c语言关于时间的两个函数
- A*算法证明
- bug---- storyBoardID 出现的报错 可能是没有clean
- 堆栈和队列的java实现
- android:修改PagerTabStrip中的背景颜色,标题字体的样式、颜色和图标以及指示条的颜色
- 【Android】安卓布局文件中xmlns属性
- self.navigationController.navigationItem 与 self.navigationItem 关系对比与分析
- PHP5踩坑记
- Android——适配器
- Win7(64Bit) 安装 PL/SQL Developer图解
- Fuel-OpenStack架构学习
- 我想对所有新程序员说的一些话
- WebView 控件学习
- 交换、路由与防火墙手记(8)