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

本文是小编为大家收集整理的关于根元素之后的文档中的标记必须是格式良好的?的处理/解决方法,可以参考本文帮助大家快速定位并解决问题,中文翻译不准确的可切换到English标签页查看源文。

问题描述

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

推荐答案

如果您搜索了此错误,则有很多帖子. 例如:

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>

其他推荐答案

尝试ctrl + shift + F xml代码,该代码将格式化代码,然后清洁项目后重试.

本文地址:https://www.itbaoku.cn/post/102787.html

问题描述

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>

推荐答案

If you would have googled this error, there are lots of post for the same. Eg:

Android app, 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. What is the cause of this?

Error : The markup in the document following the root element must be well-formed Please help I am new at android

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.

Update

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>

其他推荐答案

Try ctrl + shift + F to your xml code which will format the code and try again after cleaning the project.it will work.