安卓错误 : Error parsing XML: not well-formed (invalid token)

标签 android android-layout

我的 android xml 文件有错误。

error: Error parsing XML: not well-formed (invalid token).

我的 xml 代码是:

 <RelativeLayout
        android:layout_width="match_parent"
        android:layout_height="105dp" 
        android:background="@drawable/white"

    <EditText
        android:id="@+id/editText1"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:ems="10"
        android:inputType="textMultiLine" 
            android:lines="6" 
            android:minLines="6" 
            android:gravity="top|left" 
            android:maxLines="10" 
            android:scrollbars="vertical"
            android:hint="Comments on my post"
        <requestFocus />
    </EditText>
</RelativeLayout>

最佳答案

您的 RelativeLayout 中缺少以下命名空间和右括号 (>)。

xmlns:android="http://schemas.android.com/apk/res/android"

因此,将它们添加到 RelativeLayout...如下...

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="105dp" 
    android:background="@drawable/white">

您还缺少 EditText 的右括号 (>)...将右括号添加为...

<EditText
    android:id="@+id/editText1"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:ems="10"
    android:inputType="textMultiLine" 
    android:lines="6" 
    android:minLines="6" 
    android:gravity="top|left" 
    android:maxLines="10" 
    android:scrollbars="vertical"
    android:hint="Comments on my post">

然后清理构建您的项目。

关于安卓错误 : Error parsing XML: not well-formed (invalid token),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21872691/

相关文章:

android - 布局在 StatusBar 和 Soft Keys 下

java - 在 Android 中实现计时器 请参阅下面的代码以获取帮助

Android客户端FirebaseApp初始化错误

java - Android 布局快速问题

android - 单选按钮波纹切断

java - 为什么我的横幅出现在我的主视图下?

java - 新值 EditText 未显示,没有任何错误

android - 在 android 中播放 mp3 文件时遇到问题

java - Android:异常解码未知类型

Android Room LiveData Observer 未更新