0

我已经在 android 中创建了一个应用程序,但是当我在不同屏幕尺寸的 android 手机上测试我的应用程序时,外观和感觉不稳定。

我的问题是如何为所有安卓手机设置你的应用程序显示?

4

2 回答 2

2
 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.)
于 2012-05-14T11:30:22.553 回答
0

最好的方法是使用相对布局而不是像 layout_height = "20dp" 这样的硬编码值,或者使用两种类型的布局 1 分别用于横向和纵向,这应该可以解决您的最大问题。但是还有另一种方法可以通过动态设置视图属性来使每个屏幕都完全相同...这是

DisplayMetrics 指标 = new DisplayMetrics(); getWindowManager().getDefaultDisplay().getMetrics(metrics);

    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);
于 2012-05-15T04:17:17.297 回答