I am designing a basic sudoko GAME for android. I want a 4x4 table with all cells as squares in it.
I am trying this with the 16 Buttons in a TableLayout
.
My way looks like this
they are rectange in shape :(
my xml
<TableLayout
android:id="@+id/tl"
android:layout_width="match_parent"
android:layout_height="fill_parent"
android:gravity="center" >
<TableRow
android:id="@+id/tableRow1"
android:layout_width="wrap_content"
android:layout_height="fill_parent"
android:gravity="center" >
<Button
android:id="@+id/button1"
style="@style/box_sky_blue"
android:layout_weight="1"
android:text="1" />
<Button
android:id="@+id/button2"
style="@style/box_sky_blue"
android:layout_weight="1"
android:text="2" />
<Button
android:id="@+id/button3"
style="@style/box_sky_blue"
android:layout_weight="1"
android:text="3" />
<Button
android:id="@+id/button4"
style="@style/box_sky_blue"
android:layout_weight="1"
android:text="4" />
</TableRow>
<TableRow
android:id="@+id/tableRow2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="center" >
<Button
android:id="@+id/button5"
style="@style/box_sky_blue"
android:layout_weight="1"
android:text="5" />
<Button
android:id="@+id/button6"
style="@style/box_sky_blue"
android:layout_weight="1"
android:text="6" />
<Button
android:id="@+id/button7"
style="@style/box_sky_blue"
android:layout_weight="1"
android:text="7" />
<Button
android:id="@+id/button8"
style="@style/box_sky_blue"
android:layout_weight="1"
android:text="8" />
</TableRow>
<TableRow
android:id="@+id/tableRow3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="center" >
<Button
android:id="@+id/button9"
style="@style/box_sky_blue"
android:layout_weight="1"
android:text="9" />
<Button
android:id="@+id/button10"
style="@style/box_sky_blue"
android:layout_weight="1"
android:text="7" />
<Button
android:id="@+id/button11"
style="@style/box_sky_blue"
android:layout_weight="1"
android:text="8" />
<Button
android:id="@+id/button12"
style="@style/box_sky_blue"
android:layout_weight="1"
android:text="7" />
</TableRow>
<TableRow
android:id="@+id/tableRow3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="center" >
<Button
android:id="@+id/button13"
style="@style/box_sky_blue"
android:layout_weight="1"
android:text="9" />
<Button
android:id="@+id/button14"
style="@style/box_sky_blue"
android:layout_weight="1"
android:text="7" />
<Button
android:id="@+id/button15"
style="@style/box_sky_blue"
android:layout_weight="1"
android:text="8" />
<Button
android:id="@+id/button16"
style="@style/box_sky_blue"
android:layout_weight="1"
android:text="7" />
</TableRow>
</TableLayout>
here is box sky blue
<style name="box_sky_blue">
<item name="android:layout_width">wrap_content</item>
<item name="android:layout_height">wrap_content</item>
<item name="android:background">@color/box_color_sky_blue</item>
<item name="android:layout_margin">5dp</item>
<item name="android:padding">5dp</item>
<item name="android:textSize">20sp</item>
<item name="android:gravity">center</item>
<item name="android:textColor">#ffffff</item>
</style>
How to make them sqaure since I have square of 4x4,5x5 & 6x6