![](/img/trans.png)
[英]Error: The markup in the document following the root element must be well-formed
[英]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的新手
等等。 基本上,它说整个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.