【问题标题】:Error parsing XML mismatched tag解析 XML 不匹配标签时出错
【发布时间】:2012-08-16 02:36:15
【问题描述】:
<LinearLayout 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">

    <LinearLayout
        android:id="@+id/tab1"
        android:layout_width="match_parent"
        android:layout_height="match_parent">

        <ScrollView
            android:id="@+id/scrollView1"
            android:layout_width="wrap_content"
            android:layout_height="match_parent">

            <LinearLayout
                android:layout_width="wrap_content"
                android:layout_height="match_parent"
                android:orientation="vertical">

                <TextView
                    android:id="@+id/textView1"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:layout_gravity="center"
                    android:gravity="center"
                    android:text="About the course"
                    android:textColor="#0000ff"
                    android:textSize="20dp" />

                <TextView
                    android:id="@+id/textView2"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:layout_marginTop="10dp"
                    android:text="This course equips you the skills to handle and manage the technology that is so vital in the field of media and communication, namely digital communication, wireless devices, broadband, media design and other emerging media and telecommunication technologies."
                    android:textColor="#0000ff"
                    android:textSize="14dp" />
                <ImageView
                    android:id="@+id/imageView1"
                    android:layout_width="214dp"
                    android:layout_height="171dp"
                    android:layout_marginTop="10dp"
                    android:adjustViewBounds="true"
                    android:padding="10dp"
                    android:scaleType="fitStart"
                    android:src="@drawable/cinema4d"
                    android:layout_gravity="center" />
                <TextView
                    android:id="@+id/textView3"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:layout_marginTop="10dp"
                    android:textColor="#0000ff"
                    android:text="What you learn:"
                    android:textSize="14dp" />
                <TextView
                    android:id="@+id/textView4"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:layout_marginTop="10dp"
                    android:textColor="#0000ff"
                    android:textSize="14dp" 
                    android:text="Enrol in subjects on the fundamentals of media and communication technology and refine your specialisation by choosing elective subjects in areas such as multimedia networking and applications, wireless and mobile communications, and digital broadcasting with emphasis on a 'hands-on. minds-on' approach."/>
                <ImageView
                    android:id="@+id/imageView1"
                    android:layout_width="214dp"
                    android:layout_height="171dp"
                    android:layout_marginTop="10dp"
                    android:adjustViewBounds="true"
                    android:padding="10dp"
                    android:scaleType="fitStart"
                    android:src="@drawable/fdmp"
                    android:layout_gravity="center" />                
        </ScrollView>
    </LinearLayout>    
</LinearLayout>

我的代码很好,我测试了几次,直到出现解析 xml 不匹配的错误,我似乎找不到错误。 添加图像视图后,当我尝试构建时出现以下错误: 在此行找到多个注释: - 错误:解析 XML 时出错:标签不匹配 - 元素类型“LinearLayout”必须由匹配的结束标签“”终止。 有人知道我的代码有什么问题吗? 谢谢

【问题讨论】:

    标签: android xml parsing tags mismatch


    【解决方案1】:

    错误信息相当准确:

    在此行发现多个注释:- 错误:解析 XML 时出错: 不匹配的标签 - 元素类型“LinearLayout”必须终止 通过匹配的结束标签

    您的 xml 会打开两个 &lt;LinearLayout&gt; 标签(一个在第一行,一个作为 &lt;ScrollView&gt; 的第一个元素),但它只关闭一个。

    在&lt;/ScrollView&gt; 之前添加&lt;/LinearLayout&gt; 应该可以解决此问题。

    【讨论】:

      【解决方案2】:

      &lt;/ScrollView&gt; 之前需要一个&lt;/LinearLayout&gt; 标签

      【讨论】:

        猜你喜欢
        • 2014-04-26
        • 2015-07-10
        • 2013-12-16
        • 2018-03-03
        • 1970-01-01
        • 2015-12-05
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多