横の画像ボタンに配置したい画像が5つありますLinearLayout
。画像はディスク上にさまざまなサイズで保存されますが、レイアウトに配置するときは、同じ高さで、0.5、1、1、1、0.5の異なる重み(レイアウトの重みの合計を意味する)にする必要がありますは4)です。このコードを使用しようとしましたが、機能しませんでした。
<LinearLayout
android:id="@+id/linearLayout2"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:weightSum="4" >
<ImageButton
android:id="@+id/scrollLeft"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/left"
android:layout_weight="0.5" />
<ImageButton
android:id="@+id/dog"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/dog"
android:layout_weight="1" />
<ImageButton
android:id="@+id/fish"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/fish"
android:layout_weight="1" />
<ImageButton
android:id="@+id/cat"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/cat"
android:layout_weight="1" />
<ImageButton
android:id="@+id/scrollRight"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/right"
android:layout_weight="0.5" />
</LinearLayout>
これを機能させるために変更できるパラメータはlayout_width
ありlayout_height
ますか、それともボタンごとにJavaコードからスケーリングされたビットマップを作成する必要がありますか?ありがとう!