Android XML文档格式不正确

Android XML文档格式不正确,android,xml,Android,Xml,我不知道为什么我会得到“根元素后面的文档中的标记必须格式良好”。我试图在android项目的res/menu下使用mainxml中的以下代码。请帮忙 <?xml version="1.0" encoding="utf-8"?> <ScrollView xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="fill_parent" android:layou

我不知道为什么我会得到“根元素后面的文档中的标记必须格式良好”。我试图在android项目的res/menu下使用mainxml中的以下代码。请帮忙

<?xml version="1.0" encoding="utf-8"?>
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent" >

    <LinearLayout
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        android:gravity="center_vertical|left"
        android:orientation="vertical" >

        <LinearLayout
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:orientation="horizontal" >

            <TextView
                style="@style/inputLabel"
                android:text="@string/cardHolderName" />

            <EditText
                android:id="@+id/cardHolderNameInput"
                style="@style/textInput"
                android:layout_width="fill_parent"
                android:singleLine="true" />
        </LinearLayout>

        <LinearLayout
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:orientation="horizontal" >

            <TextView
                style="@style/inputLabel"
                android:text="@string/cardNumber" />

            <EditText
                android:id="@+id/cardNumberInput"
                style="@style/textInput"
                android:layout_width="fill_parent"
                android:numeric="integer"
                android:singleLine="true" />
        </LinearLayout>

        <LinearLayout
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:orientation="horizontal" >

            <TextView
                style="@style/inputLabel"
                android:paddingRight="40sp"
                android:text="@string/expirationDate" />

            <TextView
                style="@style/inputLabel"
                android:text="@string/expirationMonth" />

            <EditText
                android:id="@+id/expirationMonthInput"
                style="@style/textInput"
                android:layout_width="50sp"
                android:numeric="integer"
                android:singleLine="true" />

            <TextView
                style="@style/inputLabel"
                android:paddingLeft="10sp"
                android:text="@string/expirationYear" />

            <EditText
                android:id="@+id/expirationYearInput"
                style="@style/textInput"
                android:layout_width="50sp"
                android:numeric="integer"
                android:singleLine="true" />
        </LinearLayout>

        <LinearLayout
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:orientation="horizontal" >

            <TextView
                style="@style/inputLabel"
                android:text="@string/cvv" />

            <EditText
                android:id="@+id/cvvInput"
                style="@style/textInput"
                android:layout_width="fill_parent"
                android:numeric="integer"
                android:singleLine="true" />
        </LinearLayout>

        <LinearLayout
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:orientation="horizontal" >

            <TextView
                style="@style/inputLabel"
                android:text="@string/amount" />

            <EditText
                android:id="@+id/amountInput"
                style="@style/textInput"
                android:layout_width="fill_parent"
                android:numeric="integer|decimal"
                android:singleLine="true" />
        </LinearLayout>

        <LinearLayout
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:gravity="center_horizontal"
            android:orientation="horizontal" >

            <Button
                android:id="@+id/submitAction"
                style="@style/action"
                android:clickable="true"
                android:text="@string/submit" />
        </LinearLayout>
    </LinearLayout>

</ScrollView>


任何帮助都将不胜感激。谢谢。

您很可能有未关闭的元素,或者没有包含android名称空间。请发布整个xml文档以进一步澄清

编辑:
您已将xml放在“菜单”下,而不是“布局”下。

很可能您有未关闭的元素或未包含android命名空间。请发布整个xml文档以进一步澄清

编辑:
您已将xml放在“菜单”下而不是“布局”下。

您不能将布局文件放在“资源/菜单”下。将
main.xml
文件移动到
res/layout
,这样就可以了。

res/menu下不能有布局文件。将
main.xml
文件移动到
res/layout
,应该可以了。

这是xml中唯一的内容吗?发布xml文档的全部内容。还有,文件在哪里,文件名是什么?我觉得很好。你试过清理你的项目吗?或者复制文件的内容。删除该文件并重新制作,然后将其粘贴回该文件可能会解决问题。抱歉,该文件名为main.xml,位于android项目的res/menu文件夹下。正如我的回答所示,这是一个布局文件,而不是菜单,这是xml中唯一的内容吗?发布xml文档的全部内容。还有,文件在哪里,文件名是什么?我觉得很好。你试过清理你的项目吗?或者复制文件的内容。删除该文件并重新制作,然后将其粘贴回该文件可能会解决问题。抱歉,该文件名为main.xml,位于android项目的res/menu文件夹下。正如我的回答所示,这是一个布局文件,而不是菜单