求解救 在AndroidStudio 种的自定义属性命名空间问题
开发环境:windows8.1 64bit AndroidStudio 2.0
我定义了一个属性文件 attrs.xml 位于res/values 目录下
内容是
<?xml version="1.0" encoding="utf-8"?>
<resources>
<declare-styleable name="SettingItemView">
<attr name="title_value" format="string" />
<attr name="desc_on" format="string" />
<attr name="desc_off" format="string" />
</declare-styleable>
</resources>
然后在使用的时候
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
xmlns:michael="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
tools:context="com.michael.administrator.myapplication.activity.SettingActivity">
<com.michael.administrator.myapplication.view.SettingItemView
android:id="@+id/siv"
android:layout_width="match_parent"
android:layout_height="wrap_content"
michael:title_value="title_value"
michael:desc_on="desc_on"
michael:desc_off="desc_off"
/>
以michael 起头的3个标签的内容都获取不到,后台打印均为空
如果我将 上面内容的
xmlns:michael="http://schemas.android.com/apk/res-auto"
改为我的包名
xmlns:michael="com.michael.administrator.myapplication"
app则可以获取到 我这三个自定义标签的内容,后台也能打印出来.但是无法发布,发布的话会提示 命名空间要以 http:// 开头
然后写成 xmlns:michael="http://com.michael.administrator.myapplication"
效果又跟原来一样 获取不到自定义标签内容
求大牛帮忙