首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 移动开发 > Android >

为什么小弟我的这段android .xml文件会报错

2013-04-09 
为什么我的这段android.xml文件会报错报错::Unexpected namespace prefix xmlns found for tag LinearLa

为什么我的这段android .xml文件会报错

报错::Unexpected namespace prefix "xmlns" found for tag LinearLayout




      android:layout_marginRight="20dp">
      <TextView 
         android:layout_width="wrap_content"
         android:layout_height="wrap_content" 
         android:text="密    码:"
         android:textSize="20dp" />
      <EditText 
         android:layout_width="fill_parent"
         android:layout_height="wrap_content" 
         android:password="true" />
   </LinearLayout>
</LinearLayout>
[解决办法]
或者点击 Project -> Clean 然后再 Run As
[解决办法]
一般只需要顶层地Layout需要xmlns:android="http://schemas.android.com/apk/res/android" 属性。
  其他的Layout去掉该xmlns属性。
[解决办法]

引用:
报错::Unexpected namespace prefix "xmlns" found for tag LinearLayout





Plain Text code
?



1234567891011121314151617181920212223242526

<?xml version="1.0" encoding="utf-8"?> <LinearLay……


去除中间两个LinearLayout 的xmlns:android属性


<?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"     android:orientation="vertical" android:layout_width="fill_parent"     android:layout_height="fill_parent">       <LinearLayout        android:orientation="horizontal" android:layout_width="fill_parent"         android:layout_height="fill_parent" android:layout_marginLeft="20dp"         android:layout_marginRight="20dp">         <TextView android:layout_width="wrap_content" android:text="用户名:"             android:textSize="20dp" android:layout_height="wrap_content" />         <EditText android:layout_width="fill_parent"             android:layout_height="wrap_content" />     </LinearLayout>     <LinearLayout        android:orientation="horizontal" android:layout_width="fill_parent"         android:layout_height="fill_parent" android:layout_marginLeft="20dp"         android:layout_marginRight="20dp">         <TextView android:layout_width="wrap_content"             android:layout_height="wrap_content" android:text="密    码:"             android:textSize="20dp" />         <EditText android:layout_width="fill_parent"             android:layout_height="wrap_content" android:password="true" />     </LinearLayout>   </LinearLayout> 



[解决办法]
建议去掉中间两个layout的xmlns:android="http://schemas.android.com/apk/res/android" ,有可能是因为这个报错,具体可以看下xml文件的规范。。
[解决办法]
命名空间重复定义了,去掉后面多余的xmlns:android="http://schemas.android.com/apk/res/android" ,保留最前面的那个linearlayout的那个就可以了

热点排行