Android的XML错误解析XML:文档元素后的垃圾 [英] Android XML Error parsing XML: junk after document element
问题描述
我收到此错误:
在这一行找到多个注释: - 根元素必须是下列文件中的标记良好 形成。 - 错误:错误解析XML:文档元素后的垃圾
Multiple annotations found at this line: - The markup in the document following the root element must be well- formed. - error: Error parsing XML: junk after document element
这是出现在这个XML文件中的第二个TextView的。
This is appearing on the second TextView in this xml file.
<?xml version="1.0" encoding="utf-8"?>
<TextView xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/text1"
android:textSize="16sp"
android:textStyle="bold"
android:textColor="#FFFF00"
android:layout_width="fill_parent"
android:layout_height="fill_parent"></TextView>
<TextView android:id="@+id/text2"
android:textSize="12sp"
android:textStyle="bold"
android:layout_width="wrap_content"
android:layout_height="fill_parent"
></TextView>
<TextView android:id="@+id/text3"
android:typeface="sans"
android:textSize="14sp"
android:textStyle="italic"
android:layout_width="wrap_content"
android:layout_height="wrap_content"></TextView>
这是我作出了错误的任何想法? 所有帮助AP preciated。
Any ideas on the mistake I am making? All help is appreciated.
推荐答案
这是XML文档只能有1根元素。你有3个这样的元素。你应该附上的TextView元素的布局中,如LinearLayout中:
An XML document can only have 1 root element. You have 3 such elements. You should enclose your TextView elements inside a layout, such as a LinearLayout:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent">
<!-- TextView elements here -->
</LinearLayout>
删除的xmlns第一TextView元素的属性。
Remove the xmlns attribute on the first TextView element.
这篇关于Android的XML错误解析XML:文档元素后的垃圾的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!