【发布时间】:2013-06-04 09:38:22
【问题描述】:
我现在很困惑。我尝试制作不同的图像并将它们放在适当的文件夹(xhdpi,ldpi)中,但我的应用程序不适用于从 2.7 英寸到 10 英寸的每种设备类型。所以我决定为不同的屏幕尺寸制作不同的布局。我正在从此代码中获取以英寸为单位的设备尺寸 -
DisplayMetrics dm = new DisplayMetrics();
getWindowManager().getDefaultDisplay().getMetrics(dm);
double x = Math.pow(dm.widthPixels/dm.xdpi,2);
double y = Math.pow(dm.heightPixels/dm.ydpi,2);
double screenInches = Math.sqrt(x+y);
Log.d("debug","Screen inches : " + screenInches);
现在我想要的是,如果设备大小在 2.7 左右,我的应用开始使用自定义文件夹中的布局。这可能吗?
【问题讨论】:
-
创建不同的布局不是好的做法。仅使用一种布局并确保您的小部件在没有任何硬编码值的情况下定位/对齐。
标签: android android-layout android-emulator android-screen-support android-screen