2 つの大きなボタンを並べて配置したいと考えています。それらは画面全体を占有する必要があります (つまり、それぞれの幅の半分)。ボタンの背景に画像を含める必要があります(ボタンよりもはるかに大きいソース画像から縮小されます)。ボタンの高さを画像の縦横比で指定したい。できれば、すべて xml で行います。それはできますか?
次のことを試してみましたが、画像の幅が高さよりもはるかに大きいにもかかわらず、ボタンが正方形に見えることがわかりました (両方の画像の寸法は同じです)。
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content" >
<Button
android:id="@+id/rep_button"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_weight="0.1"
android:background="@drawable/repeating"
android:text="" />
<Button
android:id="@+id/oneoff_button"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_weight="0.1"
android:background="@drawable/oneoff"
android:text="" />
</LinearLayout>