0

小さな問題が発生しました。画像の特定の部分に配置されるボタンを作成したいと考えています。

私のオリジナルは、画像を LinearLayout の背景として使用し、ボタンをマップの上に配置していました。マージンを変更することで思い通りに配置できましたが、画面サイズが変わったときに問題が発生しました。

ソースコード:

<LinearLayout  android:orientation="vertical" xmlns:android="http://schemas.android.com/apk/res/android" android:layout_height="fill_parent" android:layout_width="fill_parent">

<LinearLayout
    android:layout_width="300dp"
    android:layout_height="300dp"
    android:background="@drawable/howlingabyssmap"
    android:orientation="horizontal" >
    <ImageButton
        android:id="@+id/imageButton2"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentRight="true"
        android:layout_alignParentTop="true"
        android:layout_alignParentTop="true"
        android:layout_marginRight="120dp"
        android:layout_marginTop="180dp"
        android:background="@drawable/health"
        android:src="@drawable/health"/>

</LinearLayout>

これを解決する方法はありますか?weightSum と layout_weight を使用してみましたが、解決できませんでした。

4

1 に答える 1

0

LinearLayout と ImageButton を使用する代わりに、FrameLayout 内で Button と ImageView を使用する

于 2013-05-15T21:12:36.713 に答える