Android でアプリケーションを作成しましたが、さまざまな画面サイズの Android 携帯でアプリケーションをテストすると、ルック アンド フィールが安定しません。
私の質問は、すべての Android フォンのアプリケーション表示を設定する方法ですか?
Android でアプリケーションを作成しましたが、さまざまな画面サイズの Android 携帯でアプリケーションをテストすると、ルック アンド フィールが安定しません。
私の質問は、すべての Android フォンのアプリケーション表示を設定する方法ですか?
Android has included support for three screen-size “buckets” since 1.6,
based on these “dp” units: “normal” is currently the most popular device format (originally 320x480, more recently higher-density 480x800);
“small” is for smaller screens, and “large” is for “substantially larger” screens.
Devices that fall in the “large” bucket include the Dell Streak and original 7” Samsung Galaxy Tab.
Android 2.3 introduced a new bucket size “xlarge”, in preparation for the approximately-10” tablets (such as the Motorola Xoom) that Android 3.0 was designed to support.
xlarge screens are at least 960dp x 720dp.
large screens are at least 640dp x 480dp.
normal screens are at least 470dp x 320dp.
small screens are at least 426dp x 320dp.
(Android does not currently support screens smaller than this.)
最善の方法は、layout_height = "20dp" のようなハードコード値の代わりに相対レイアウトを使用するか、横向きと縦向きにそれぞれ 1 つずつ 2 種類のレイアウトを使用することです。これにより、問題が最大限に解決されます。しかし、ビュー属性を動的に設定することにより、すべての画面でまったく同じにする別の方法があります...これは
DisplayMetrics メトリック = 新しい DisplayMetrics(); getWindowManager().getDefaultDisplay().getMetrics(メトリックス);
int height = metrics.heightPixels;
int width = metrics.widthPixels;
Button Button1 = (Button) findViewById(R.id.button1);
Button Button2 = (Button) findViewById(R.id.button2);
Button1.setWidth(width / 2);
Button2.setWidth(width / 2);