android中的屏幕尺寸

时间:2012-05-14 10:34:58

标签: android android-layout

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

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

2 个答案:

答案 0 :(得分: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.)

答案 1 :(得分:0)

最好的方法是使用相对布局而不是像layout_height =“20dp”这样的硬编码值 或者使用两种类型的布局1,每种布局用于风景和肖像,这应该解决你问题的最大化。但是还有另一种方法可以通过动态设置视图属性来为每个屏幕提供完全相同的...这是

DisplayMetrics metrics = new 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);