Too much gap between table rows

PeakGen

Please have a look at the following code

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:paddingTop="@dimen/activity_vertical_margin"
    tools:context=".HomeScreen" >

    <TableLayout
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        android:stretchColumns="*"
        android:layout_margin="10dp"
        android:layout_centerInParent="true"
        android:weightSum="4" >

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

            <LinearLayout
                android:layout_width="0dp"
                android:layout_height="wrap_content"
                android:layout_weight=".3"
                android:background="@android:drawable/btn_default"
                android:clickable="true"
                android:gravity="center"
                android:orientation="vertical" >

                <ImageView
                    android:id="@+id/imageView1"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:padding="5dp"
                    android:src="@drawable/ic_launcher" />

                <TextView
                    android:id="@+id/textView1"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:text="@string/fStr"
                    android:textAppearance="?android:attr/textAppearanceSmall" />

            </LinearLayout>

            <LinearLayout
                android:layout_width="0dp"
                android:layout_height="wrap_content"
                android:layout_weight=".3"
                android:gravity="center"
                android:clickable="true"
                android:background="@android:drawable/btn_default"
                android:orientation="vertical" >

                <ImageView
                    android:id="@+id/imageView2"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:padding="5dp"
                    android:src="@drawable/ic_launcher" />

                <TextView
                    android:id="@+id/textView2"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:text="@string/rStr"
                    android:textAppearance="?android:attr/textAppearanceSmall" />

            </LinearLayout>

            <LinearLayout
                android:layout_width="0dp"
                android:layout_height="wrap_content"
                android:layout_weight=".3"
                android:gravity="center"
                android:background="@android:drawable/btn_default"
                android:clickable="true"
                android:orientation="vertical" >

                <ImageView
                    android:id="@+id/imageView3"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:padding="5dp"
                    android:src="@drawable/ic_launcher" />

                <TextView
                    android:id="@+id/textView3"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:text="@string/sStr"
                    android:textAppearance="?android:attr/textAppearanceSmall" />

            </LinearLayout>

        </TableRow>

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

            <LinearLayout
                android:layout_width="0dp"
                android:layout_height="wrap_content"
                android:layout_weight=".3"
                android:gravity="center"
                android:background="@android:drawable/btn_default"
                android:clickable="true"
                android:orientation="vertical" >

                <ImageView
                    android:id="@+id/imageView4"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:padding="5dp"
                    android:src="@drawable/ic_launcher" />

                <TextView
                    android:id="@+id/textView4"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:text="@string/cStr"
                    android:textAppearance="?android:attr/textAppearanceSmall" />

            </LinearLayout>

            <LinearLayout
                android:layout_width="0dp"
                android:layout_height="wrap_content"
                android:layout_weight=".3"
                android:gravity="center"
                android:background="@android:drawable/btn_default"
                android:clickable="true"
                android:orientation="vertical" >

                <ImageView
                    android:id="@+id/imageView5"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:padding="5dp"
                    android:src="@drawable/ic_launcher" />

                <TextView
                    android:id="@+id/textView5"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:text="@string/aStr"
                    android:textAppearance="?android:attr/textAppearanceSmall" />

            </LinearLayout>

            <LinearLayout
                android:layout_width="0dp"
                android:layout_height="wrap_content"
                android:layout_weight=".3"
                android:gravity="center"
                android:background="@android:drawable/btn_default"
                android:clickable="true"
                android:orientation="vertical" >

                <ImageView
                    android:id="@+id/imageView6"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:padding="5dp"
                    android:src="@drawable/ic_launcher" />

                <TextView
                    android:id="@+id/textView6"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:text="@string/lStr"
                    android:textAppearance="?android:attr/textAppearanceSmall" />

            </LinearLayout>

        </TableRow>

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

            <LinearLayout
                android:layout_width="0dp"
                android:layout_height="wrap_content"
                android:layout_weight=".3"
                android:gravity="center"
                android:background="@android:drawable/btn_default"
                android:clickable="true"
                android:orientation="vertical" >

                <ImageView
                    android:id="@+id/imageView7"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:padding="5dp"
                    android:src="@drawable/ic_launcher" />

                <TextView
                    android:id="@+id/textView7"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:text="@string/oStr"
                    android:textAppearance="?android:attr/textAppearanceSmall" />

            </LinearLayout>

            <LinearLayout
                android:layout_width="0dp"
                android:layout_height="wrap_content"
                android:layout_weight=".3"
                android:gravity="center"
                android:background="@android:drawable/btn_default"
                android:clickable="true"
                android:orientation="vertical" >

                <ImageView
                    android:id="@+id/imageView8"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:padding="5dp"
                    android:src="@drawable/ic_launcher" />

                <TextView
                    android:id="@+id/textView8"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:text="@string/tStr"
                    android:textAppearance="?android:attr/textAppearanceSmall" />

            </LinearLayout>

            <LinearLayout
                android:layout_width="0dp"
                android:layout_height="wrap_content"
                android:layout_weight=".3"
                android:gravity="center"
                android:background="@android:drawable/btn_default"
                android:clickable="true"
                android:orientation="vertical" >

                <ImageView
                    android:id="@+id/imageView9"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:padding="5dp"
                    android:src="@drawable/ic_launcher" />

                <TextView
                    android:id="@+id/textView9"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:text="@string/eStr"
                    android:textAppearance="?android:attr/textAppearanceSmall" />

            </LinearLayout>

        </TableRow>

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

            <LinearLayout
                android:layout_width="0dp"
                android:layout_height="wrap_content"
                android:layout_weight=".3"
                android:gravity="center"
                android:background="@android:drawable/btn_default"
                android:clickable="true"
                android:orientation="vertical" >

                <ImageView
                    android:id="@+id/imageView10"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:padding="5dp"
                    android:src="@drawable/ic_launcher" />

                <TextView
                    android:id="@+id/textView10"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:text="@string/hStr"
                    android:textAppearance="?android:attr/textAppearanceSmall" />

            </LinearLayout>

            <LinearLayout
                android:layout_width="0dp"
                android:layout_height="wrap_content"
                android:layout_weight=".3"
                android:gravity="center"
                android:background="@android:drawable/btn_default"
                android:clickable="true"
                android:orientation="vertical" >

                <ImageView
                    android:id="@+id/imageView11"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:padding="5dp"
                    android:src="@drawable/ic_launcher" />

                <TextView
                    android:id="@+id/textView11"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:text="@string/dStr"
                    android:textAppearance="?android:attr/textAppearanceSmall" />

            </LinearLayout>

            <LinearLayout
                android:layout_width="0dp"
                android:layout_height="wrap_content"
                android:layout_weight=".3"
                android:gravity="center"
                android:background="@android:drawable/btn_default"
                android:clickable="true"
                android:orientation="vertical" >

                <ImageView
                    android:id="@+id/imageView12"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:padding="5dp"
                    android:src="@drawable/ic_launcher" />

                <TextView
                    android:id="@+id/textView12"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:text="@string/aStr"
                    android:textAppearance="?android:attr/textAppearanceSmall" />

            </LinearLayout>

        </TableRow>
    </TableLayout>

</RelativeLayout>

In WVGA 5.1 Screen, this generates the following UI

enter image description here

As you can see, there is a massive gap between rows. I want to avoid this, so it will look good in all smartphones. How can I do this?

Manishika

Make height & width of tableRow as fill_parent and height of every LinearLayout also as fill_parent

Use this data

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:paddingTop="@dimen/activity_vertical_margin"
    tools:context=".HomeScreen" >

    <TableLayout
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        android:stretchColumns="*"
        android:layout_margin="10dp"
        android:layout_centerInParent="true"
        android:weightSum="4" >

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

            <LinearLayout
                android:layout_width="0dp"
                android:layout_height="fill_parent"
                android:layout_weight=".3"
                android:background="@android:drawable/btn_default"
                android:clickable="true"
                android:gravity="center"
                android:orientation="vertical" >

                <ImageView
                    android:id="@+id/imageView1"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:padding="5dp"
                    android:src="@drawable/ic_launcher" />

                <TextView
                    android:id="@+id/textView1"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:text="@string/fStr"
                    android:textAppearance="?android:attr/textAppearanceSmall" />

            </LinearLayout>

            <LinearLayout
                android:layout_width="0dp"
                android:layout_height="fill_parent"
                android:layout_weight=".3"
                android:gravity="center"
                android:clickable="true"
                android:background="@android:drawable/btn_default"
                android:orientation="vertical" >

                <ImageView
                    android:id="@+id/imageView2"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:padding="5dp"
                    android:src="@drawable/ic_launcher" />

                <TextView
                    android:id="@+id/textView2"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:text="@string/rStr"
                    android:textAppearance="?android:attr/textAppearanceSmall" />

            </LinearLayout>

            <LinearLayout
                android:layout_width="0dp"
                android:layout_height="fill_parent"
                android:layout_weight=".3"
                android:gravity="center"
                android:background="@android:drawable/btn_default"
                android:clickable="true"
                android:orientation="vertical" >

                <ImageView
                    android:id="@+id/imageView3"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:padding="5dp"
                    android:src="@drawable/ic_launcher" />

                <TextView
                    android:id="@+id/textView3"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:text="@string/sStr"
                    android:textAppearance="?android:attr/textAppearanceSmall" />

            </LinearLayout>

        </TableRow>

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

            <LinearLayout
                android:layout_width="0dp"
                android:layout_height="fill_parent"
                android:layout_weight=".3"
                android:gravity="center"
                android:background="@android:drawable/btn_default"
                android:clickable="true"
                android:orientation="vertical" >

                <ImageView
                    android:id="@+id/imageView4"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:padding="5dp"
                    android:src="@drawable/ic_launcher" />

                <TextView
                    android:id="@+id/textView4"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:text="@string/cStr"
                    android:textAppearance="?android:attr/textAppearanceSmall" />

            </LinearLayout>

            <LinearLayout
                android:layout_width="0dp"
                android:layout_height="fill_parent"
                android:layout_weight=".3"
                android:gravity="center"
                android:background="@android:drawable/btn_default"
                android:clickable="true"
                android:orientation="vertical" >

                <ImageView
                    android:id="@+id/imageView5"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:padding="5dp"
                    android:src="@drawable/ic_launcher" />

                <TextView
                    android:id="@+id/textView5"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:text="@string/aStr"
                    android:textAppearance="?android:attr/textAppearanceSmall" />

            </LinearLayout>

            <LinearLayout
                android:layout_width="0dp"
                android:layout_height="fill_parent"
                android:layout_weight=".3"
                android:gravity="center"
                android:background="@android:drawable/btn_default"
                android:clickable="true"
                android:orientation="vertical" >

                <ImageView
                    android:id="@+id/imageView6"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:padding="5dp"
                    android:src="@drawable/ic_launcher" />

                <TextView
                    android:id="@+id/textView6"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:text="@string/lStr"
                    android:textAppearance="?android:attr/textAppearanceSmall" />

            </LinearLayout>

        </TableRow>

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

            <LinearLayout
                android:layout_width="0dp"
                android:layout_height="fill_parent"
                android:layout_weight=".3"
                android:gravity="center"
                android:background="@android:drawable/btn_default"
                android:clickable="true"
                android:orientation="vertical" >

                <ImageView
                    android:id="@+id/imageView7"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:padding="5dp"
                    android:src="@drawable/ic_launcher" />

                <TextView
                    android:id="@+id/textView7"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:text="@string/oStr"
                    android:textAppearance="?android:attr/textAppearanceSmall" />

            </LinearLayout>

            <LinearLayout
                android:layout_width="0dp"
                android:layout_height="fill_parent"
                android:layout_weight=".3"
                android:gravity="center"
                android:background="@android:drawable/btn_default"
                android:clickable="true"
                android:orientation="vertical" >

                <ImageView
                    android:id="@+id/imageView8"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:padding="5dp"
                    android:src="@drawable/ic_launcher" />

                <TextView
                    android:id="@+id/textView8"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:text="@string/tStr"
                    android:textAppearance="?android:attr/textAppearanceSmall" />

            </LinearLayout>

            <LinearLayout
                android:layout_width="0dp"
                android:layout_height="fill_parent"
                android:layout_weight=".3"
                android:gravity="center"
                android:background="@android:drawable/btn_default"
                android:clickable="true"
                android:orientation="vertical" >

                <ImageView
                    android:id="@+id/imageView9"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:padding="5dp"
                    android:src="@drawable/ic_launcher" />

                <TextView
                    android:id="@+id/textView9"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:text="@string/eStr"
                    android:textAppearance="?android:attr/textAppearanceSmall" />

            </LinearLayout>

        </TableRow>

        <TableRow
            android:id="@+id/tableRow4"
            android:layout_width="fill_parent"
            android:layout_height="fill_parent"
            android:layout_weight="1" >

            <LinearLayout
                android:layout_width="0dp"
                android:layout_height="fill_parent"
                android:layout_weight=".3"
                android:gravity="center"
                android:background="@android:drawable/btn_default"
                android:clickable="true"
                android:orientation="vertical" >

                <ImageView
                    android:id="@+id/imageView10"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:padding="5dp"
                    android:src="@drawable/ic_launcher" />

                <TextView
                    android:id="@+id/textView10"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:text="@string/hStr"
                    android:textAppearance="?android:attr/textAppearanceSmall" />

            </LinearLayout>

            <LinearLayout
                android:layout_width="0dp"
                android:layout_height="fill_parent"
                android:layout_weight=".3"
                android:gravity="center"
                android:background="@android:drawable/btn_default"
                android:clickable="true"
                android:orientation="vertical" >

                <ImageView
                    android:id="@+id/imageView11"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:padding="5dp"
                    android:src="@drawable/ic_launcher" />

                <TextView
                    android:id="@+id/textView11"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:text="@string/dStr"
                    android:textAppearance="?android:attr/textAppearanceSmall" />

            </LinearLayout>

            <LinearLayout
                android:layout_width="0dp"
                android:layout_height="fill_parent"
                android:layout_weight=".3"
                android:gravity="center"
                android:background="@android:drawable/btn_default"
                android:clickable="true"
                android:orientation="vertical" >

                <ImageView
                    android:id="@+id/imageView12"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:padding="5dp"
                    android:src="@drawable/ic_launcher" />

                <TextView
                    android:id="@+id/textView12"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:text="@string/aStr"
                    android:textAppearance="?android:attr/textAppearanceSmall" />

            </LinearLayout>

        </TableRow>
    </TableLayout>

</RelativeLayout>

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

Too much gap between table rows

From Dev

There are too much gap of time between different position of global memory for atomicAdd functions

From Dev

Gap between rows in tablelayout

From Dev

Too much blinking rows in ListView

From Dev

Too much blinking rows in ListView

From Dev

Too much space in between CardViews

From Dev

Clear gap between span and table

From Dev

Clear gap between span and table

From Dev

Clear gap between span and table

From Dev

SOSL statement returns too much rows

From Dev

Deleting of rows in UITableView takes too much time

From Dev

Removing large gap between rows in flexbox layout

From Dev

Flutter how to get rid of the gap between rows

From Dev

Matplotlib table plot, how to add gap between the graph and table

From Dev

Retrieve IDs with a minimum time gap between consecutive rows

From Dev

Why there is no gap between rows of less than 2 images?

From Dev

Using datediff to find the lowest value with a given gap between rows

From Dev

How do I remove the gap between the two rows of images?

From Dev

Too much spacing between StackPanel items in Windows Store app

From Dev

How to reduce too much space between two columns with Bootstrap

From Dev

Font rendering issue in urxvt -- too much space between characters

From Dev

MySQL subtraction between varchar fields returns decimal with too much precision

From Dev

Achartengine graph displaying too much space between values

From Dev

Too much space between bars in matplotlib bar chart

From Dev

Group addon taking up too much space in bootstrap table

From Dev

mysql clean a log table when there are too much records

From Dev

Table reload taking too much time to update the cells

From Dev

When is too much voltage too much on a PC?

From Java

Reduce too big gap between C3 widget and surrounding text in Rmarkdown

Related Related

  1. 1

    Too much gap between table rows

  2. 2

    There are too much gap of time between different position of global memory for atomicAdd functions

  3. 3

    Gap between rows in tablelayout

  4. 4

    Too much blinking rows in ListView

  5. 5

    Too much blinking rows in ListView

  6. 6

    Too much space in between CardViews

  7. 7

    Clear gap between span and table

  8. 8

    Clear gap between span and table

  9. 9

    Clear gap between span and table

  10. 10

    SOSL statement returns too much rows

  11. 11

    Deleting of rows in UITableView takes too much time

  12. 12

    Removing large gap between rows in flexbox layout

  13. 13

    Flutter how to get rid of the gap between rows

  14. 14

    Matplotlib table plot, how to add gap between the graph and table

  15. 15

    Retrieve IDs with a minimum time gap between consecutive rows

  16. 16

    Why there is no gap between rows of less than 2 images?

  17. 17

    Using datediff to find the lowest value with a given gap between rows

  18. 18

    How do I remove the gap between the two rows of images?

  19. 19

    Too much spacing between StackPanel items in Windows Store app

  20. 20

    How to reduce too much space between two columns with Bootstrap

  21. 21

    Font rendering issue in urxvt -- too much space between characters

  22. 22

    MySQL subtraction between varchar fields returns decimal with too much precision

  23. 23

    Achartengine graph displaying too much space between values

  24. 24

    Too much space between bars in matplotlib bar chart

  25. 25

    Group addon taking up too much space in bootstrap table

  26. 26

    mysql clean a log table when there are too much records

  27. 27

    Table reload taking too much time to update the cells

  28. 28

    When is too much voltage too much on a PC?

  29. 29

    Reduce too big gap between C3 widget and surrounding text in Rmarkdown

HotTag

Archive