android中的屏幕大小
我已经用android创建了一个应用程序,但当我在不同屏幕尺寸的android手机上测试我的应用程序时,它的外观和感觉并不稳定android中的屏幕大小,android,android-layout,Android,Android Layout,我已经用android创建了一个应用程序,但当我在不同屏幕尺寸的android手机上测试我的应用程序时,它的外观和感觉并不稳定 我的问题是如何为所有android手机设置应用程序显示 最好的方法是使用相对布局,而不是像layout\u height=“20dp”这样的硬编码值 Android has included support for three screen-size “buckets” since 1.6, based on these “dp” units: “normal” is
我的问题是如何为所有android手机设置应用程序显示 最好的方法是使用相对布局,而不是像layout\u height=“20dp”这样的硬编码值
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种用于横向和纵向,这应该可以解决您的最大问题。但是有另一种方法可以让每个屏幕都完全相同,通过动态设置视图属性…这是
DisplayMetrics=新的DisplayMetrics();
getWindowManager().getDefaultDisplay().getMetrics(度量)
这个问题在这里已经回答了很多次了。我想我昨天回答了一次。这是您想要的:。另外,使用谷歌。使用不同的绘图工具。不要硬连线你的布局。使用相对布局………..k,padma我首先在三星galaxy y手机上测试我的应用程序,它工作正常,但当我在三星tab上尝试相同的应用程序时,它看起来并不太好,我想提供对我的应用程序的全局访问,以便每个android都能以相同的外观使用它,我想从我的应用程序中删除屏幕大小依赖项?可能是其ok的重复项,但如何在单个应用程序中定义这些权限,以便每个Android手机都可以使用我的应用程序,无论是屏幕大小、大小、普通还是xlarge,请通过代码显示。
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);