在安卓开发中,在布局文件中如果出现Unexpected namespace prefix "xmlns" found for tag RelativeLayout 错误,一般情况下都是命名空间定义发生冲突所致,解决办法就是在多个布局格式后,只保留一个xmlns:android="http://schemas.android.com/apk/res/android", 其余的全删掉。如下所示,只保留<TabHost>后面一个命名空间的定义。
<TabHost xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@android:id/tabhost"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<LinearLayout
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
。。。。。。。。
.。。。。。。。。
<AbsoluteLayout
android:id="@+id/AbsoluteLayout03"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
>
</LinearLayout>
</AbsoluteLayout>
</TabHost>
本文介绍了在Android开发中遇到的布局文件命名空间冲突问题及其解决方案。通常表现为Unexpected namespace prefix错误,解决方法是在布局文件中仅保留一个核心的命名空间定义,即xmlns:android,并移除其他多余的命名空间声明。

305

被折叠的 条评论
为什么被折叠?



