Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/222.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
在Android RelativeLayout中,有没有一种方法可以将父对象减去一个固定的数字?_Android_Android Relativelayout_Android Imagebutton_Fill Parent - Fatal编程技术网

在Android RelativeLayout中,有没有一种方法可以将父对象减去一个固定的数字?

在Android RelativeLayout中,有没有一种方法可以将父对象减去一个固定的数字?,android,android-relativelayout,android-imagebutton,fill-parent,Android,Android Relativelayout,Android Imagebutton,Fill Parent,我有一个ImageButton,我想填充它的父RelativeLayout容器的宽度,但减去一些dp,所以它有一些左右填充。我尝试了fill\u parent-10dp,但这会导致错误,无法呈现。在ImageButton上放置一个android:layout\u margin=“10dp”,以及 android:layout_width="fill_parent" android:layout_height="fill_parent" 使用xml属性android:layout\u margi

我有一个
ImageButton
,我想填充它的父
RelativeLayout
容器的宽度,但减去一些
dp
,所以它有一些左右填充。我尝试了
fill\u parent-10dp
,但这会导致错误,无法呈现。

在ImageButton上放置一个
android:layout\u margin=“10dp”
,以及

android:layout_width="fill_parent"
android:layout_height="fill_parent"
  • 使用xml属性
    android:layout\u marginLeft
    指定额外的 视图左侧的空间
  • 使用xml属性
    android:layout_marginRight
    指定 视图右侧的额外空间
  • 使用xml属性
    android:layout_marginTop
    指定额外的 视图顶部的空间
  • 使用xml属性
    android:layout_marginBottom
    指定 视图底部的额外空间
  • 使用xml属性
    android:layout\u 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"
    
    填充和边距呢?