Reputation: 989
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
I want to remove the space between two rows. How to do that ?
Upvotes: 3
Views: 3034
Reputation: 24848
Try to add this android:scaleType="fitXY"
properties to all your ImageView and in xml
Upvotes: 4
Reputation: 19858
Remove all margins and padding from the TableLayout
and TableRow
s
<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
Upvotes: 2