1

I have a Imagebutton with a icon of a barcode as the background. I am trying to put a paddingtop on the item so its not touching the top of the screen.

The paddingtop works for the textview but not the imagebutton?

Any tricks I can try to move it 5dp down?

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
              android:layout_width="match_parent"
              android:layout_height="match_parent">


    <TableLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:weightSum="100">

    <TableRow
        android:weightSum="100">

    <TextView
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:layout_gravity="clip_vertical"
        android:paddingLeft="5dp"
        android:paddingTop="10dp"
        android:layout_weight="50"
        android:text="Barcode"/>


    <ImageButton
        android:id="@+id/btnScan"
        android:paddingTop="5dp"
        android:layout_width="50dp"
        android:layout_height="25dp"
        android:background="@drawable/barcode"/>

    </TableRow>
    </TableLayout>



</RelativeLayout>

enter image description here

4

1 回答 1

1

使用布局边距向下移动图像按钮。

<ImageButton
    android:id="@+id/btnScan"
    android:layout_marginTop="5dp"
    android:layout_width="50dp"
    android:layout_height="25dp"
    android:background="@drawable/barcode"/>

有关边距与填充的更多信息,请参阅此答案

于 2015-02-28T09:17:12.830 回答