I'm trying to make a GridLayout of 8x8 buttons (like a minesweeper). I'm managing the weights to all have the same width but it works fine until 4 buttons. When I add the 5th button in column 4 they expand the width full screen. This is my xml:
<GridLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/GridLayout1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="8dp"
android:columnCount="8"
android:orientation="horizontal"
android:rowCount="8"
tools:context=".MainActivity">
<Button
android:id="@+id/b1"
android:layout_column="0"
android:layout_columnWeight="1"
android:layout_row="0"
android:text="B" />
<Button
android:id="@+id/b2"
android:layout_column="1"
android:layout_columnWeight="1"
android:layout_row="0"
android:text="B" />
<Button
android:id="@+id/b3"
android:layout_column="2"
android:layout_columnWeight="1"
android:layout_row="0"
android:text="B" />
<Button
android:id="@+id/b4"
android:layout_column="3"
android:layout_columnWeight="1"
android:layout_row="0"
android:text="B" />
</GridLayout>
Design with 4 button: 4 button
When I add the 5th button to the 4 column: button expands
Thank you!