簡體   English   中英

根元素后面的文檔中的標記必須格式正確嗎?

[英]The markup in the document following the root element must be well-formed?

我在第9行的activity_main.xml中收到此錯誤,我不知道為什么需要幫助。

<FrameLayout
    android:id="@+id/main_content"
    android:layout_width="match_parent"
    android:layout_height="0dp"
    android:layout_weight="1" >

<WebView
    android:id="@+id/webView"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent" />
</FrameLayout>

嘗試ctrl + shift + F到您的xml代碼,這將格式化代碼並在清理項目后重試。它將起作用。

如果您會用Google搜索此錯誤,則有很多相同的帖子。 例如:

Android應用,根元素后的文檔中的標記必須格式正確

根元素后面的文檔中的標記必須格式正確。 這是什么原因?

錯誤:根元素后面的文檔中的標記必須格式正確,請幫助我是android的新手

等等。 基本上,它說整個XML文件只能有一個根元素 您顯示的xml片段看起來不完整。 只需確保XML文件只有一個根元素,其余的都是該根元素的子元素。 希望這可以幫助。 如果沒有,請發布完整的XML文件,以幫助我們更好地工作。

更新資料

在上面顯示的代碼中,您有兩個FrameLayout根元素。 應該只有一個。 因此(根據您的需要)將其更改為如下所示,以便僅存在一個根元素:

<?xml version="1.0" encoding="utf-8"?>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/fullscreen_custom_content"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:background="#FF000000">
    <FrameLayout
        android:id="@+id/main_content"
        android:layout_width="match_parent"
        android:layout_height="match_parent"/>
    <WebView
        android:id="@+id/webView"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent" />

</FrameLayout>

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM