问题描述
- android studio报错XML:not well-formed
-
< RelativeLayout xmlns:android ="http://schemas.android.com/apk/res/android"
xmlns:tools= "http://schemas.android.com/tools"
android:layout_width= "match_parent"
android:layout_height= "match_parent"
android:background= "@drawable/baidi" >< ImageView android:id ="@+id/login_button" android:layout_width ="wrap_content" android:layout_height ="wrap_content" android:layout_centerHorizontal ="true" android:layout_marginTop ="50dp" android:src ="@drawable/yezizhi" /> <!--整体边框块的颜色 --> <LinearLayout android:id ="@+id/input" android:layout_width ="fill_parent" android:layout_height ="wrap_content" android:layout_below ="@id/login_button" android:layout_marginLeft ="28.0dip" android:layout_marginRight ="28.0dip" android:background ="@drawable/baidi" android:orientation ="vertical" > <!--账号框颜色--> < LinearLayout android:layout_width ="fill_parent" android:layout_height ="44.0dip" android:background ="@drawable/baidi" android:gravity ="center_vertical" android:orientation ="horizontal" > < EditText android:id ="@+id/searchEditText" android:layout_width ="0dp" android:layout_height ="fill_parent" android:layout_weight ="1" android:background ="@null" android:ems ="10" android:imeOptions ="actionDone" android:singleLine ="true" android:textSize ="16sp" android:hint="输入账户名" android:text="输入账户名"> < requestFocus /> </ EditText> </ LinearLayout> < View android:layout_width ="fill_parent" android:layout_height ="1.0px" android:layout_marginLeft ="1.0px" android:layout_marginRight ="1.0px" android:background ="#ffc0c3c4" /> <!--隐形显示文字,点击消失--> < EditText android:id ="@+id/password" android:layout_width ="fill_parent" android:layout_height ="44.0dip" android:background ="#00ffffff" android:gravity ="center_vertical" android:inputType ="textPassword" android:maxLength ="16" android:maxLines ="1" android:textColor ="#ff1d1d1d" android:textColorHint ="#ff666666" android:textSize ="16.0sp" android:hint="密码" android:text="输入密码" /> </LinearLayout > <Button android:id ="@+id/buton1" android:layout_width ="270dp" android:background ="@drawable/landi" android:paddingTop ="5.0dip" android:layout_height ="50dp" android:gravity ="center" android:textSize ="20dp" android:text = "登录" android:layout_alignBottom="@id/input" android:layout_centerHorizontal="true" />
</ RelativeLayout>
报错XML:not well-formed
错误地方在 android:layout_alignBottom="@id/input"
和 android:layout_below ="@id/login_button"
解决方案
你很多xml元素开始都有一个空格,这是不规范的,应该去掉
解决方案二:
@id/input 改成@+id/input @id/login_button改成 @i+d/
时间: 2024-11-02 21:46:07