Android XML tablerow


Ask by : Henrey Bellchester November 04, 2012 04:08

PICTURE : www.gunzhaxplz.com/xmlAndroid.png my problem http://gunzhaxplz.com/xmlAndroid.png

PREFACE : I am making an application that requires to have 6 images on a tablerow.

PROBLEMS : The images I can't seem to resize and the last image on the right is out of the screen

Here is the XML :

<TableLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/TableLayout1"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="horizontal" >

<TableRow
    android:id="@+id/tableRow1"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content" >




    <ImageButton
        android:id="@+id/imageButton1"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:src="@drawable/golem_square" />





    <ImageButton
        android:id="@+id/imageButton2"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:src="@drawable/lizard_square" />




    <ImageButton
        android:id="@+id/imageButton3"
        android:layout_width="wrap_content"
        android:layout_height="match_parent"
        android:src="@drawable/baron_square" />



    <ImageButton
        android:id="@+id/imageButton4"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:src="@drawable/dragon_square" />

</TableRow>

<TableRow
    android:id="@+id/tableRow2"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content" >

    <ImageButton
        android:id="@+id/ImageButton03"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:src="@drawable/golem_square" />

    <ImageButton
        android:id="@+id/ImageButton01"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:src="@drawable/lizard_square" />

    <ImageButton
        android:id="@+id/ImageButton02"
        android:layout_width="wrap_content"
        android:layout_height="match_parent"
        android:src="@drawable/baron_square" />

    <ImageButton
        android:id="@+id/ImageButton04"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:src="@drawable/dragon_square" />
</TableRow>

View original question

Answer by : Matt ClarkNovember 04, 2012 04:08

Try setting the following parameters in each ImageButton

android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:adjustViewBounds="true"
android:maxWidth="32dpi"
android:maxHeight="32dpi"
View original answer