Note that there are some explanatory texts on larger screens.

plurals
  1. POAndroid: create square cell table
    primarykey
    data
    text
    <p>I am designing a basic tic tac toe game for android as my 'Hello World' project. I want a 3x3 table with all cells as squares in it. </p> <p>The way I've done makes the column shrink if there is nothing in any of the cells in it. I am trying this with the 9 TextViews in a GridLayout. </p> <p>I welcome all suggestions to do this.</p> <p>My way looks like this - <img src="https://i.stack.imgur.com/9VXsW.png" alt="enter image description here"></p> <pre><code>&lt;RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" style="@style/LayoutStyle" tools:context=".GameBoard"&gt; &lt;GridLayout style="@style/GameBoardGrid" android:id="@+id/gridTitle"&gt; &lt;TextView android:id="@+id/tile00" style="@style/GameTile" android:layout_column="0" android:layout_row="0" android:text=""/&gt; &lt;TextView android:id="@+id/tile01" style="@style/GameTile" android:layout_column="1" android:layout_row="0" android:text="X"/&gt; &lt;TextView android:id="@+id/tile02" style="@style/GameTile" android:layout_column="2" android:layout_row="0" android:text="O"/&gt; &lt;TextView android:id="@+id/tile10" style="@style/GameTile" android:layout_column="0" android:layout_row="1" android:text=""/&gt; &lt;TextView android:id="@+id/tile11" style="@style/GameTile" android:layout_column="1" android:layout_row="1" android:text="O"/&gt; &lt;TextView android:id="@+id/tile12" style="@style/GameTile" android:layout_column="2" android:layout_row="1" android:text="X"/&gt; &lt;TextView android:id="@+id/tile20" style="@style/GameTile" android:layout_column="0" android:layout_row="2" android:text=""/&gt; &lt;TextView android:id="@+id/tile21" style="@style/GameTile" android:layout_column="1" android:layout_row="2" android:text="X"/&gt; &lt;TextView android:id="@+id/tile22" style="@style/GameTile" android:layout_column="2" android:layout_row="2" android:text="O"/&gt; &lt;/GridLayout&gt; &lt;/RelativeLayout&gt; </code></pre> <p>Where, the style GameTile is -</p> <pre><code>&lt;style name="GameTile"&gt; &lt;item name="android:textSize"&gt;60sp&lt;/item&gt; &lt;item name="android:layout_gravity"&gt;fill&lt;/item&gt; &lt;item name="android:gravity"&gt;center&lt;/item&gt; &lt;item name="android:paddingLeft"&gt;@dimen/padding_grid_text&lt;/item&gt; &lt;item name="android:paddingRight"&gt;@dimen/padding_grid_text&lt;/item&gt; &lt;item name="android:fontFamily"&gt;Roboto-Thin&lt;/item&gt; &lt;item name="android:background"&gt;@color/gray&lt;/item&gt; &lt;item name="android:layout_margin"&gt;@dimen/margin_grid_cell&lt;/item&gt; &lt;item name="android:layout_weight"&gt;1&lt;/item&gt; &lt;/style&gt; </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload