私の Android アプリは、実際のデバイス (Samsung Galaxy Mini http://www.gsmarena.com/samsung_galaxy_mini_s5570-3725.php ) とエミュレーターでは異なって見えます。
240x320 LDPI (120ppi) 用に最新の SDK、AVD をセットアップしました。
私のレイアウト: 私は 4 つの項目を持つ垂直 linerlayout を持っています: 4x 水平 linerlayout
<LinearLayout
android:id="@+id/LinearLayoutMainLines"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical" >
<LinearLayout
android:id="@+id/LinearLayoutMainLine1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center_horizontal"
android:orientation="horizontal" >
</LinearLayout>
....
<LinearLayout
android:id="@+id/LinearLayoutMainLine4"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center_horizontal"
android:orientation="horizontal" >
</LinearLayout>
</LinearLayout>
次に、コードから、4 つの「LinearLayoutMainLine」すべてに 10 個のボタンを追加します。最後に、画面に 4x10 個のボタンがあります。
Button button = new Button(_context);
button.setTypeface( Typeface.MONOSPACE, Typeface.BOLD);
button.setOnClickListener(this);
button.setTextColor(0xFFFFFFFF);
button.setText(letter);
button.setBackgroundResource(id);
....later....
forall (buttons_line1)
layout1.addView(button);
....
forall (buttons_line4)
layout4.addView(button);
ボタンの背景画像とテキストはコードによって随時変更されるため、作成時と同じではないことに注意してください。ただし、使用されるすべての画像は同じサイズ (再確認済み) であり、ボタンのテキストは常に 1 文字です。
問題:
エミュレーター上: サイズが 19x36 の 4x10 ボタンがあります。
Mini デバイスの場合: サイズが 19x38 の 3x10 ボタンがあり、4 行目は 19x32 です。このボタンの最後の行は短いため、テキストは半分にカットされています。
使用されている画像: res\ldpi\button.9.png はすべて 18x26 サイズです。
この違いの原因は何ですか?
マージされたスクリーンショットを添付しています。左がデバイス、右がエミュレータです。
仕様上、Mini は ~127 ppi ですが、これが問題なのでしょうか? しかし、エミュレータには密度の固定リストがあり、120 が最も近いため、これをエミュレータ用に設定することはできません。しかし、私が述べたようにそれは問題ありません。
どんなヒントでも大歓迎です。ありがとう