0

これらの画像の使用:

ここに画像の説明を入力してください (333x300) ここに画像の説明を入力してください (1680x1050)

そしてこのレイアウト:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:layout_margin="12dp"
    android:orientation="vertical">

    <LinearLayout 
        android:orientation="horizontal"
        android:layout_width="match_parent" 
        android:layout_height="0dp"
        android:layout_weight="1"
        android:gravity="center">    

        <ImageButton
            android:layout_width="0dp"
            android:layout_height="match_parent"
            android:layout_weight="1"
            android:scaleType="fitCenter"
            android:src="@drawable/apple" />

        <ImageButton
            android:layout_width="0dp"
            android:layout_height="match_parent"
            android:layout_weight="1"
            android:scaleType="fitCenter"
            android:src="@drawable/apple" />
    </LinearLayout>

    <LinearLayout 
        android:orientation="horizontal"
        android:layout_width="match_parent" 
        android:layout_height="0dp"
        android:layout_weight="1"
        android:gravity="center">   

        <ImageButton
            style="@style/OtherButton"
            android:layout_width="0dp"
            android:layout_height="match_parent"
            android:layout_weight="1"
            android:scaleType="fitCenter"
            android:src="@drawable/orange" />

        <ImageButton
            style="@style/OtherButton"
            android:layout_width="0dp"
            android:layout_height="match_parent"
            android:layout_weight="1"
            android:scaleType="fitCenter"
            android:src="@drawable/orange" />

    </LinearLayout>
</LinearLayout>

この結果が得られます:

ここに画像の説明を入力してください

単一のネストされたレイアウトのみで、リンゴとオレンジのボタンは同じサイズです。Eclipseをいじってみたところ、画像が大きいほどボタンが高くなる傾向があることに気付きましたが、相対的な比率は特定のパターンに従っていないようです。

ボタンの高さが異なるのはなぜですか?画面の解像度と密度に合わせて拡大縮小できる別の方法はありますか?

4

1 に答える 1

1

以下の変更を行います。

メインの親レイアウトでlayout_heightをandroid:layout_height="fill_parent"

于 2012-12-31T05:43:06.430 に答える