2017-10-07 20 views
0

我想將紅色複製到所有其餘的正方形,但是當我嘗試這樣做時,出現錯誤「列索引(開始+跨度)不得超過列數」列索引(開始+跨度)不得超過列數

enter image description here

我設置列和行數到3,我的XML代碼是下面。

<?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> 

回答

0

我已經設置網格視圖中的行和列數到3兩,當我複製紅點到下一個單元,而不是選擇出現在綠色網格線,我把它粘貼在電池旁邊的電池更遠離細胞。它只適用於將點複製到緊貼數字的網格旁邊。我也可以在XML視圖中做到這一點,確保我堅持指定的數字。

相關問題