解决方案 »

  1.   

    我这个新手也刚刚碰到这个问题,然后我发现是格式问题,就是你把上下的代码对齐了就没有问题了,你试试下面这个改了格式的看看吧:
    <?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 
          xmlns:android="http://schemas.android.com/apk/res/android"
          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 
          xmlns:android="http://schemas.android.com/apk/res/android"
          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>
      

  2.   

    或者点击 Project -> Clean 然后再 Run As
      

  3.   

    一般只需要顶层地Layout需要xmlns:android="http://schemas.android.com/apk/res/android" 属性。
      其他的Layout去掉该xmlns属性。
      

  4.   


    去除中间两个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> 
      

  5.   

    建议去掉中间两个layout的xmlns:android="http://schemas.android.com/apk/res/android" ,有可能是因为这个报错,具体可以看下xml文件的规范。。
      

  6.   

    命名空间重复定义了,去掉后面多余的xmlns:android="http://schemas.android.com/apk/res/android" ,保留最前面的那个linearlayout的那个就可以了
      

  7.   

    去除中间两个LinearLayout 的xmlns:android属性,因为命名空间重复定义了