【问题标题】:Error:(7) Error parsing XML: junk after document element错误:(7) 解析 XML 时出错:文档元素后出现垃圾
【发布时间】:2015-07-19 22:32:21
【问题描述】:

所以基本上它是这个老栗子......我看到这个问题被问了很多,但无法将他们的解决方案与我的解决方案联系起来,所以也许你还可以帮助我。

这是我的 activity_splash.xml

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:background="@color/primary_dark"
    android:id="@+id/imgLogo"/>

    <ImageView
        android:id="@+id/imgLogo"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:src="@drawable/splash"
        android:contentDescription=""
        android:layout_centerVertical="true"
        android:layout_alignParentLeft="true"
        android:layout_alignParentStart="true" />

    <TextView
        android:id="@+id/AppVersion"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:layout_marginBottom="10dp"
        android:textSize="14sp"
        android:textColor="@android:color/white"
        android:gravity="center_horizontal"
        android:layout_alignParentBottom="true" />

    <ProgressBar
        android:id="@+id/progress_bar"
        style="?android:attr/progressBarStyle"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_centerInParent="true"
        android:layout_below="@+id/imgLogo"/>

    <com.app.tvng.blogpress.views.VerticalTextView
        android:id="@+id/companyname"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_gravity="left|center_vertical"
        android:layout_alignParentBottom="true"
        android:layout_marginLeft="3dip"
        android:layout_marginBottom="4dip"
        android:padding="4dip"
        android:textSize="12sp"
        android:textColor="@color/white"
        android:text="@string/copyright"/>

    </RelativeLayout>

感谢您的帮助

【问题讨论】:

  • 它是否指向任何一行?你能发布完整的错误日志吗
  • @cooervo 完整的错误日志:错误:(7) 解析 XML 时出错:文档元素后出现垃圾

标签: android xml


【解决方案1】:

尝试包含工具命名空间:xmlns:tools="http://schemas.android.com/tools" 并使用tools:background="@color/primary_dark" 而不是android:background="@color/primary_dark"

像这样:

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
                xmlns:tools="http://schemas.android.com/tools"
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                tools:background="@color/primary_dark"
                android:id="@+id/imgLogo">

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2010-11-24
    • 2013-01-22
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-01-29
    相关资源
    最近更新 更多