一見簡単だと思っていたものを達成しようとしていますが、負荷を調査してもまだ苦労しています。
イメージの一部がボタンを上に置くべき領域である背景として機能する ImageView を設定しています。たとえば、背景は次のようになります。
これは fitCenter に設定されているため、次のようにすべての画面タイプで正しい縦横比でスケーリングされます。
今、私は次のように白い領域に ImageButtons を配置しようとしています:
各 Imagebutton を背景の imageView の左上に配置し、マージンを設定して適切な場所に配置することで、これを試みています。これは一部の画面タイプで機能しますが、たとえば、デバイスが背景画像よりも小さいために背景のサイズが変更されると、上部のボタンのサイズが変更されないことがわかり、次のような効果が得られます。
これが私が試しているレイアウトのタイプです(ここにはボタンが1つだけあります):
<RelativeLayout android:layout_height="match_parent" android:layout_width="match_parent" xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/outer" xmlns:tools="http://schemas.android.com/tools">
<ImageView android:layout_height="wrap_content" android:layout_width="wrap_content" android:id="@+id/imageView1" android:src="@drawable/no_pills_pane" android:scaleType="fitCenter" android:adjustViewBounds="true" android:layout_centerVertical="true" android:layout_centerHorizontal="true"/>
<ImageButton android:layout_height="wrap_content" android:layout_width="wrap_content" android:id="@+id/imageButton1" android:src="@drawable/pill_pink" android:scaleType="fitXY" android:background="@null" android:layout_marginTop="50dp" android:layout_marginLeft="44dp" android:layout_alignTop="@id/imageView1" android:layout_alignLeft="@id/imageView1"/>
</RelativeLayout>
これについてもっと簡単な方法があるに違いないと確信しています。どんな助けでも大歓迎です。
ありがとうサイモン