Question

I have use Tablelayout to display 6 different images in a screen. Here is my xml code,

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:background="@color/background"
    android:orientation="vertical"
    tools:context=".MainMenu" >

    <TableLayout
        android:id="@+id/tableLayout"
        android:layout_width="match_parent"
        android:layout_height="match_parent" >

        <TableRow
            android:id="@+id/tableRow1"
            android:layout_width="wrap_content"
            android:layout_height="0dp"
            android:layout_weight="1" >

            <ImageView
                android:id="@+id/image1"
                android:layout_width="0dp"
                android:layout_height="match_parent"
                android:layout_gravity="center"
                android:layout_weight="1"
                android:contentDescription="@string/app_name"
                android:src="@drawable/temp" />

            <ImageView
                android:id="@+id/image2"
                android:layout_width="0dp"
                android:layout_height="match_parent"
                android:layout_gravity="center"
                android:layout_weight="1"
                android:contentDescription="@string/app_name"
                android:src="@drawable/temp" />
        </TableRow>

        <TableRow
            android:id="@+id/tableRow2"
            android:layout_width="wrap_content"
            android:layout_height="0dp"
            android:layout_weight="1" >

            <ImageView
                android:id="@+id/image3"
                android:layout_width="0dp"
                android:layout_height="match_parent"
                android:layout_gravity="center"
                android:layout_weight="1"
                android:contentDescription="@string/app_name"
                android:src="@drawable/temp" />

            <ImageView
                android:id="@+id/image4"
                android:layout_width="0dp"
                android:layout_height="match_parent"
                android:layout_gravity="center"
                android:layout_weight="1"
                android:contentDescription="@string/app_name"
                android:src="@drawable/temp" />
        </TableRow>

        <TableRow
            android:id="@+id/tableRow3"
            android:layout_width="wrap_content"
            android:layout_height="0dp"
            android:layout_weight="1" >

            <ImageView
                android:id="@+id/image5"
                android:layout_width="0dp"
                android:layout_height="match_parent"
                android:layout_gravity="center"
                android:layout_weight="1"
                android:contentDescription="@string/app_name"
                android:src="@drawable/temp" />

            <ImageView
                android:id="@+id/image6"
                android:layout_width="0dp"
                android:layout_height="match_parent"
                android:layout_gravity="center"
                android:layout_weight="1"
                android:contentDescription="@string/app_name"
                android:src="@drawable/temp" />
        </TableRow>
    </TableLayout>

</LinearLayout>

The output is like below image

enter image description here

I want to remove the space between two rows. How to do that ?

Was it helpful?

Solution

Try to add this android:scaleType="fitXY" properties to all your ImageView and in xml

OTHER TIPS

Remove all margins and padding from the TableLayout and TableRows

<TableLayout
    android:padding="0dip"           <!-- add this -->
    android:layout_margin="0dip"     <!-- add this -->
    android:id="@+id/tableLayout"
    android:layout_width="match_parent"
    android:layout_height="match_parent" >

And..

    <TableRow
        android:padding="0dip"       <!-- add this -->
        android:layout_margin="0dip" <!-- add this -->
        android:id="@+id/tableRow3"
        android:layout_width="wrap_content"
        android:layout_height="0dp"
        android:layout_weight="1" >

For all of your table rows

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top