2017-10-07 2 views
0

J'essaye de copier le do rouge à tous les autres carrés mais quand j'essaye de faire cela, j'obtiens l'erreur "column index (start + span) ne doit pas dépasser le nombre de colonnes »les index de colonne (start + span) ne doivent pas dépasser le nombre de colonnes

enter image description here

Je mets la colonne et le nombre de lignes à 3. mon code XML est ci-dessous.

<?xml version="1.0" encoding="utf-8"?> 
<RelativeLayout 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="com.example.zubai.connect3.MainActivity"> 

    <GridLayout 
     android:id="@+id/gridLayout2" 
     android:layout_width="match_parent" 
     android:layout_height="360dp" 
     android:layout_alignParentLeft="true" 
     android:layout_alignParentStart="true" 
     android:layout_centerVertical="true" 
     android:background="@drawable/board" 
     android:columnCount="3" 
     android:rowCount="3" 
     tools:ignore="UselessParent"> 


     <ImageView 
      android:id="@+id/imageView" 
      android:layout_width="90dp" 
      android:layout_height="90dp" 
      android:layout_column="0" 
      android:layout_marginLeft="20dp" 
      android:layout_marginTop="10dp" 
      android:layout_row="0" 
      android:contentDescription="" 
      android:src="@drawable/red" 
      tools:ignore="ContentDescription,RtlHardcoded" /> 

     <ImageView 
      android:id="@+id/imageView1" 
      android:layout_width="90dp" 
      android:layout_height="90dp" 
      android:layout_column="0" 
      android:layout_marginLeft="20dp" 
      android:layout_marginTop="10dp" 
      android:layout_row="0" 
      android:contentDescription="" 
      android:src="@drawable/red" 
      tools:ignore="ContentDescription,RtlHardcoded" /> 

     <ImageView 
      android:id="@+id/imageView8" 
      android:layout_width="90dp" 
      android:layout_height="90dp" 
      android:layout_column="0" 
      android:layout_marginLeft="20dp" 
      android:layout_marginTop="10dp" 
      android:layout_row="0" 
      android:contentDescription="" 
      android:src="@drawable/red" 
      tools:ignore="ContentDescription,RtlHardcoded" /> 


    </GridLayout> 

</RelativeLayout> 

Répondre

0

J'ai mis en grille ligne et la colonne comptent à 3 fois quand je copiais le point rouge à l'autre cellule au lieu de choisir la cellule à côté qui apparaît dans les lignes de la grille verte je le coller dans les cellules plus loin de la cellule. Cela ne fonctionne que lorsque vous copiez le point sur la grille à côté de celui-ci en respectant le nombre. Je pourrais aussi le faire dans la vue XML en m'assurant que je suis resté fidèle aux nombres spécifiés.