【问题标题】:"Android SDK Errors" Error parsing XML: Not well formed“Android SDK 错误”解析 XML 时出错:格式不正确
【发布时间】:2014-06-13 01:27:06
【问题描述】:

我是 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>

【问题讨论】:

  • 如果有用,别忘了接受答案:P

标签: android xml


【解决方案1】:

您需要对对象进行排序,以便所有对象都必须封装在一个布局对象中。

【讨论】:

    【解决方案2】:

    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>
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2013-02-17
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多