我有一個ImageButton,我想填充它的父RelativeLayout容器的寬度,但減去幾個DP,所以它有一些左和右填充。我嘗試了fill_parent-10dp,但是會導致錯誤並且不會呈現。有沒有在Android RelativeLayout中填充父母減去固定數字的方法?
感謝
我有一個ImageButton,我想填充它的父RelativeLayout容器的寬度,但減去幾個DP,所以它有一些左和右填充。我嘗試了fill_parent-10dp,但是會導致錯誤並且不會呈現。有沒有在Android RelativeLayout中填充父母減去固定數字的方法?
感謝
放一個android:layout_margin="10dp"
上的ImageButton,與
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_marginLeft
到指定的視圖左側額外 空間。android:layout_marginRight
在視圖右側指定 額外空間。android:layout_marginTop
指定視圖頂部的額外 空間。android:layout_marginBottom
在視圖底部指定 額外空間。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"
怎麼樣_padding_和_margin_? –