Android GridLayout: Avoiding "double margins" on rows of buttons

24 Views Asked by At

I have a GridLayout with two rows of buttons:

<GridLayout
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:layout_margin="0dp"
    android:background="@color/panelBackground"
    android:columnCount="9"
    android:rowCount="2">

and the GridLayout contains buttons, e.g.

        <ImageButton
            android:id="@+id/buttonX"
            android:layout_width="0dp"
            android:layout_height="@dimen/toolbar_button_height"
            android:layout_columnWeight="1"
            android:layout_margin="0dp"
            android:contentDescription="@string/sketch_toolbar_x"
            android:scaleType="fitCenter"
            android:src="@drawable/black" />

...and this works fine, except the buttons are slightly mis-spaced. There is a border, padding, or margin that surrounds the buttons which seems fine but in a two-row layout results in a larger space between the buttons "inside" the row than outside.

It's a minor aesthetic issue but is there a way to fix it? I can't figure out which attribute I need to change. Trying to use a LinearLayout gives a similar problem.

0

There are 0 best solutions below