我是Android SDK的新手并且遇到这两个错误,请帮助!! - 必须很好地形成根元素后面的文档中的标记 - 解析XML时出错:格式不正确
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
</LinearLayout><shape xmlns:android="http://schemas.android.com/apk/res/android" >
<gradient
android:layout_width="match_parent"
android:angle="270"
android:centerColor="#4ccbff"
android:endColor="#24b2eb"
android:startColor="#24b2eb" />
<corners
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:radius="5dp" />
</shape><LinearLayout>
</LinearLayout>
答案 0 :(得分:2)
您需要对对象进行排序,以便所有对象都必须封装在一个布局对象中。
答案 1 :(得分:0)
XML文件必须有一个所有其他视图都适合的根元素。这意味着顶部的任何标签都不能在底部关闭。
在xml文件中,您希望LinearLayout成为根元素。但是你(可能是偶然的)在你打开之后就把它关了。
请改为:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
<shape xmlns:android="http://schemas.android.com/apk/res/android" >
<gradient
android:layout_width="match_parent"
android:angle="270"
android:centerColor="#4ccbff"
android:endColor="#24b2eb"
android:startColor="#24b2eb" />
<corners
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:radius="5dp" />
</shape>
</LinearLayout>