地図であることがわかるように、非常に大きな画像を含むこの FrameLayout を作成しました。ビュー (ボタン、ImageView) を画面の外に配置したいので、ユーザーはマップ上でそれらを「見つける」ためにスクロールする必要があります。これを使用してマップ上をスクロールしています: Android: Scrolling an Imageview
<?xml version="1.0" encoding="utf-8"?>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/Container"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="#000000" >
<ImageView
android:id="@+id/map"
android:layout_width="2500dp"
android:layout_height="2000dp"
android:src="@drawable/map" />
</FrameLayout>
ボタンをプログラムで追加するか、XML に配置しようとすると、左マージンと上マージンの位置が画面のサイズ内にある場合にのみ表示されます。(480 x 800だと思います)。たとえば、これらの寸法の外側にボタンを追加すると、ビューに向かってスクロールしても、ビューは表示されません。FrameLayout のマージンが機能しないという解決策も機能しません。
これを追加すると、次のようになります。
<Button
android:id="@+id/one"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@drawable/one"
android:layout_marginLeft="420px"
android:layout_marginTop="240px"
android:layout_gravity="top"
android:onClick="click" />
このように変更すると、スクロールしても表示されなくなります。
<Button
android:id="@+id/one"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@drawable/one"
android:layout_marginLeft="1290px"
android:layout_marginTop="940px"
android:layout_gravity="top"
android:onClick="click" />
ピクセルを使用するか dp を使用するかは関係ありません。ビューはまったく表示されません。
これがなぜなのかはわかりませんが、解決策を聞きたいです。どんな助けでも大歓迎です。