35

親コンテナーの幅ImageButtonを埋めたいのですが、マイナス数を引いて、左右のパディングがあります。試してみましたが、エラーが発生してレンダリングされません。RelativeLayoutdpfill_parent-10dp

4

2 に答える 2

46

android:layout_margin="10dp"とともに、ImageButtonに

android:layout_width="fill_parent"
android:layout_height="fill_parent"
于 2012-06-23T02:15:57.630 に答える
10
  1. xml 属性android:layout_marginLeftを使用して、ビューの左側に余分なスペースを指定します。
  2. xml 属性android:layout_marginRightを使用して、ビューの右側に余分なスペースを指定します。
  3. xml 属性android:layout_marginTopを使用して、ビューの上部に余分なスペースを指定します。
  4. xml 属性android:layout_marginBottomを使用して、ビューの下側に余分なスペースを指定します。
  5. 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 に答える