1

だから私はアンドロイドプログラミングの初心者で、3つの画像ボタンを1列に並べて配置しようとしています。

問題は、それらの間のスペースを取り除くことができず、 *android:layout_marginLeft="0dp"* と *android:layout_marginRight="0dp"* をそれぞれに追加しても機能しないことです。相対レイアウトを使用しています。

助けてくれてありがとう!

XML は次のとおりです。

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent" >
<ImageButton
    android:id="@+id/ib_3"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_alignParentRight="true"
    android:layout_margin="0dp"
    android:src="icon2" />
<ImageButton
    android:id="@+id/ib_2"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_margin="0dp"
    android:layout_toLeftOf="@id/ib_3"
    android:src="icon2" />
<ImageButton
    android:id="@+id/ib_1"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_toLeftOf="@id/ib_2"
    android:layout_margin="0dp"
    android:src="icon1" />

4

1 に答える 1

4

イメージボタンの背景を null に設定する tru。ImageButton には、メーカーによって異なるデフォルトの背景があります。

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent" >
<ImageButton
    android:id="@+id/ib_3"
    android:background="@null"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_alignParentRight="true"
    android:layout_margin="0dp"
    android:src="icon2" />
<ImageButton
    android:id="@+id/ib_2"
    android:background="@null"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_margin="0dp"
    android:layout_toLeftOf="@id/ib_3"
    android:src="icon2" />
<ImageButton
    android:id="@+id/ib_1"
    android:background="@null"
    android:layout_width="wrap_content"    
    android:layout_height="wrap_content"
    android:layout_toLeftOf="@id/ib_2"
    android:layout_margin="0dp"
    android:src="icon1" />
于 2012-11-09T21:10:51.310 に答える