2

申し訳ありませんが、これは初心者の質問ですが、レイアウトが苦手です。flashlight_button を配置するレイアウトを作成して、上下のイメージビューの比率を維持するにはどうすればよいですか。

nexus s (800x480) で問題ないように見えます。

...画像 ...

しかし、明らかに、Galaxy nexus (1280 x 720) に切り替えると、このように中央のボタンが少し上に移動します (したがって、nexus s で設計された上下の余白の比率は維持されません)。

...画像...

レイアウトは次のとおりです。

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@drawable/background"
android:padding="20dp" >

<ImageView
    android:id="@+id/imageView1"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_alignParentTop="true"
    android:layout_centerHorizontal="true"
    android:layout_marginBottom="50dp"
    android:contentDescription="@string/application_logo_description"
    android:src="@drawable/mylight" />

<ImageButton
    android:id="@+id/settings_button"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_alignParentRight="true"
    android:layout_alignParentTop="true"
    android:background="@null"
    android:contentDescription="@string/settings_button_description"
    android:src="@drawable/settings_button" />

<ImageButton
    android:id="@+id/flashlight_button"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_below="@+id/imageView1"
    android:layout_centerHorizontal="true"
    android:background="@null"
    android:contentDescription="@string/flashlight_button_description"
    android:src="@drawable/flashlight_button_selector" />

<ImageView
    android:id="@+id/imageView2"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_above="@+id/ad_button"
    android:layout_centerHorizontal="true"
    android:contentDescription="@string/powered_by_description"
    android:src="@drawable/powered_by" />

<ImageButton
    android:id="@+id/ad_button"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_alignParentBottom="true"
    android:layout_centerHorizontal="true"
    android:background="@null"
    android:contentDescription="@string/ad_button_description"
    android:src="@drawable/freeml" />

そのため、上部と下部のイメージビューを親のエッジに固定し、中央のボタンをlayout_maginBottomを使用して押し下げるだけです。サイズを表現するために、さまざまな密度と明らかに密度ピクセルのスケーリングされた画像を提供しているため、大きな画面では十分ではないようです。

これを行う正しい方法は何ですか?別の .xml ファイルまたは .. ?

//申し訳ありませんが、まだ画像を投稿できません。想像していただければ幸いです。

4

1 に答える 1

1

親の中心に従って懐中電灯の画像を配置することを検討しましたか?したがって、今のところ、懐中電灯の画像を押し下げています(画像の一番上の位置に応じて)。懐中電灯の画像を中央に揃えて下マージンを設定する方が正確でしょうか(デザインに応じて少し高くするため)。

于 2012-07-26T18:25:20.347 に答える