The markup in the document following the root element must be well-formed?(根元素之后的文档中的标记必须格式正确吗?)
问题描述
我在第 9 行的 activity_main.xml 中收到此错误,我不知道为什么请帮忙.
Im getting this error in my activity_main.xml on line 9 by I have no idea why please help.
<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>
推荐答案
如果你用 google 搜索过这个错误,有很多相同的帖子.例如:
If you would have googled this error, there are lots of post for the same. Eg:
Androidapp, 文档中跟在根元素后面的标记必须格式正确
该根元素之后的文档中的标记必须格式正确.这是什么原因?
错误: 根元素后面的文档中的标记必须格式正确请帮助我是android的新手
等等.基本上它说你只能有整个 XML 文件的一个根元素.您显示的 xml 片段看起来并不完整.只需确保您只有一个 XML 文件的根元素,其余的都是该根元素的子元素.希望这可以帮助.如果没有,请发布完整的 XML 文件,以便我们更好地提供帮助.
and so on. Basically it says that you can only have one root element for the whole XML file. The xml sniplet you've shown does not look complete. Just make sure that you only have one root element for the XML file and rest of them are child of that root element. Hope this helps. If it doesn't then please do post the complete XML file for us to help better.
更新
在上面显示的代码中,您有两个 FrameLayout
根元素.应该只有一个.因此(根据您的需要)将其更改为如下所示,以便只有一个根元素:
In the code shown above you have two FrameLayout
root elements. There should be only one. So change it(based on your needs) to something like below, so that only one root element is there:
<?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>
这篇关于根元素之后的文档中的标记必须格式正确吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:根元素之后的文档中的标记必须格式正确吗?


基础教程推荐
- 减少 JVM 暂停时间 >1 秒使用 UseConcMarkSweepGC 2022-01-01
- 如何使用 Java 创建 X509 证书? 2022-01-01
- 降序排序:Java Map 2022-01-01
- 无法使用修饰符“public final"访问 java.util.Ha 2022-01-01
- “未找到匹配项"使用 matcher 的 group 方法时 2022-01-01
- 设置 bean 时出现 Nullpointerexception 2022-01-01
- Java:带有char数组的println给出乱码 2022-01-01
- 在 Libgdx 中处理屏幕的正确方法 2022-01-01
- Java Keytool 导入证书后出错,"keytool error: java.io.FileNotFoundException &拒绝访问" 2022-01-01
- FirebaseListAdapter 不推送聊天应用程序的单个项目 - Firebase-Ui 3.1 2022-01-01