我有一个ImageButton我想填充它的父RelativeLayout容器的宽度,但减去一些dp,所以它有一些左右填充。我试过fill_parent-10dp了,但这会导致错误并且不会呈现。
21207 次
2 回答
46
android:layout_margin="10dp"在 ImageButton 上放一个
android:layout_width="fill_parent"
android:layout_height="fill_parent"
于 2012-06-23T02:15:57.630 回答
10
- 使用 xml 属性
android:layout_marginLeft指定视图左侧的额外空间。 - 使用 xml 属性
android:layout_marginRight指定视图右侧的额外空间。 - 使用 xml 属性
android:layout_marginTop指定视图顶部的额外空间。 - 使用 xml 属性
android:layout_marginBottom指定视图底部的额外空间。 - 使用 xml 属性
android:layout_margin指定视图左侧、顶部、右侧和底部的额外空间。
在您的情况下,您的 ImageButton 声明如下所示
<ImageButton
android:id="@+id/button1"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:text="Button"
android:layout_marginLeft="15dp"
android:layout_marginRight="15dp"
android:src="@drawable/a"
于 2012-06-23T02:45:50.830 回答