android中的命名空间
16lz
2021-12-04
android中的xmlns是xml namespace的简称及xml文件命名空间;
以我们经常使用的android:layout_height="warp_content"为例子,android是命名空间,layout_height是属性名称,warp_content是属性值;
使用的规则是,首先定义命名空间xmlns:namespace="namespaceURI"。Android中的xml中的使用时:xmlns:前缀=http://schemas.android.com/apk/res/应用程序包名;
在我们自定义View的时候可能需要自定义一些额外的属性,这里边需要使用到了命名空间的概念。
如下一个小例子:
<?xml version="1.0" encoding="utf-8"?><LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"xmlns:myxmlns="http://schemas.android.com/apk/res/com.zbkc.custumview"android:orientation="vertical"android:layout_width="fill_parent"android:layout_height="fill_parent" ><TextView android:layout_width="fill_parent"android:layout_height="wrap_content"android:text="@string/hello" /><View myxmlns:text="sss"myxmlns:textColor="#ffffffff"/></LinearLayout>
更多相关文章
- 使用Javascript判断浏览器终端设备(PC、IOS(iphone)、Android)
- Android图表控件MPAndroidChart——曲线图+柱状图 CombinedChart
- ?android:attr/属性 与 ?android:属性
- android activity tabhost
- xmlns:android 命名空间
- Android之使用ContentResolver对通信录中的数据进行简单操作
- android语音识别之科大讯飞语音API的使用
- shape的使用
- Android动画之 Alpha与Translate结合使用