资源编译失败错误:标记不匹配

时间:2019-05-15 12:40:27

标签: java android android-layout

Android资源编译失败 C:\ Users \ TTP \ AndroidStudioProjects \ TicCrossGame \ app \ src \ main \ res \ layout \ activity_main.xml:94:错误:标记不匹配。

我检查标签是否关闭但无法理解erorr,因为我检查了所有关闭标签但仍然erorr

<?xml version="1.0" encoding="utf-8"?>
<android.support.constraint.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    tools:context=".MainActivity">

    <android.support.v7.widget.GridLayout
        android:id="@+id/gridView"
        android:layout_width="395dp"
        android:layout_height="395dp"
        android:layout_marginStart="8dp"
        android:layout_marginLeft="8dp"
        android:layout_marginTop="8dp"
        android:layout_marginEnd="8dp"
        android:layout_marginRight="8dp"
        android:layout_marginBottom="8dp"
        android:background="@drawable/grid"
        app:columnCount="3"
        app:layout_constraintBottom_toBottomOf="parent"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toTopOf="parent"
        app:rowCount="3" >



        <ImageView
            android:id="@+id/imageView1"
            android:layout_width="125dp"
            android:layout_height="126dp"
            android:layout_marginLeft="10dp"
            android:layout_marginTop="10dp"
             />

        <ImageView
            android:id="@+id/imageView2"
            android:layout_width="125dp"
            android:layout_height="126dp"
            android:layout_marginLeft="10dp"
            android:layout_marginTop="10dp"
            app:srcCompat="@drawable/cross" />

    </android.support.v7.widget.GridLayout>

</android.support.v7.widget.GridLayout>


</android.support.constraint.ConstraintLayout>

2 个答案:

答案 0 :(得分:0)

您有两个GridLayout的结束标记,只需删除其中之一即可,您的代码应该可以正常工作。如下所示:

<?xml version="1.0" encoding="utf-8"?>
<android.support.constraint.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    tools:context=".MainActivity">

    <android.support.v7.widget.GridLayout
        android:id="@+id/gridView"
        android:layout_width="395dp"
        android:layout_height="395dp"
        android:layout_marginStart="8dp"
        android:layout_marginLeft="8dp"
        android:layout_marginTop="8dp"
        android:layout_marginEnd="8dp"
        android:layout_marginRight="8dp"
        android:layout_marginBottom="8dp"
        android:background="@drawable/grid"
        app:columnCount="3"
        app:layout_constraintBottom_toBottomOf="parent"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toTopOf="parent"
        app:rowCount="3" >

        <ImageView
            android:id="@+id/imageView1"
            android:layout_width="125dp"
            android:layout_height="126dp"
            android:layout_marginLeft="10dp"
            android:layout_marginTop="10dp"
             />

        <ImageView
            android:id="@+id/imageView2"
            android:layout_width="125dp"
            android:layout_height="126dp"
            android:layout_marginLeft="10dp"
            android:layout_marginTop="10dp"
            app:srcCompat="@drawable/cross" />

    </android.support.v7.widget.GridLayout>

</android.support.constraint.ConstraintLayout>

答案 1 :(得分:0)

您有两个关闭的GridLyout标签。删除XML文件底部的其中之一:

    </android.support.v7.widget.GridLayout>