根元素之后的文档中的标记必须格式正确吗? [英] The markup in the document following the root element must be well-formed?

查看:16
本文介绍了根元素之后的文档中的标记必须格式正确吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在第 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>

这篇关于根元素之后的文档中的标记必须格式正确吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆