简体   繁体   中英

How to set margin between item on row android table layout

How to set margin between item on row android table layout

I don't know how to set margin between item on row

在此处输入图片说明

my code here I think some thing wrong I don't know how to set margin between item on 1st row and 2nd row

   <TableRow

        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:layout_marginTop="20dp"

        >

        <ImageView
            android:id="@+id/imageView4"
            android:layout_width="120dp"
            android:layout_height="120dp"
            android:layout_column="0"
            android:background="@drawable/editshape2"
             />

        <ImageView

            android:layout_width="120dp"
            android:layout_height="120dp"
            android:layout_column="1"
            android:background="@drawable/editshape2"
            />

    </TableRow>

    <TableRow

        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:layout_marginTop="20dp"

        >

        <ImageView
            android:layout_width="120dp"
            android:layout_height="120dp"
            android:layout_column="0"
            android:padding="2dp"
            android:background="@drawable/editshape2"
             />

        <ImageView
            android:layout_width="120dp"
            android:layout_height="120dp"
            android:layout_column="1"
            android:background="@drawable/editshape2"
             />

    </TableRow>

Try to add this attributes on imageView column="0"

android:layout_marginRight="5dp"
android:layout_marginEnd="5dp"

Try to add this attributes on imageView column="1"

android:layout_marginStart="5dp"
android:layout_marginLeft="5dp"

Add the following to your TableLayout :

android:divider="?android:attr/dividerHorizontal"
android:showDividers="middle"

android:layout_marginLeft="50dp" ,this can be used in second element of a row .

<ImageView
        android:id="@+id/imageView4"
        android:layout_width="120dp"
        android:layout_height="120dp"
        android:layout_column="0"
        android:background="@drawable/editshape2"
         />

    <ImageView

        android:layout_width="120dp"
        android:layout_height="120dp"
        android:layout_column="1"
        android:background="@drawable/editshape2"
        android:layout_marginLeft="50dp"
        />

</TableRow>

<TableRow

    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:layout_marginTop="20dp"

    >

    <ImageView
        android:layout_width="120dp"
        android:layout_height="120dp"
        android:layout_column="0"
        android:padding="2dp"
        android:background="@drawable/editshape2"
         />

    <ImageView
        android:layout_width="120dp"
        android:layout_height="120dp"
        android:layout_column="1"
        android:background="@drawable/editshape2"
        android:layout_marginLeft="50dp"
         />

</TableRow>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM