我正在尝试模拟 HTC Flyer,为了做到这一点,我需要模拟器自我报告为“大”屏幕尺寸。我已经指定了分辨率和正确的 dpi,但它报告为“xlarge”。android 文档(http://developer.android.com/guide/practices/screens_support.html#range)指定它应该是“xlarge”,但 HTC Flyer 设备说它是“large”。这是一些带有一些数字的调试输出:
flyer device
DisplayMetrics{density=1.0, width=600, height=1024, scaledDensity=1.0, xdpi=169.99738, ydpi=169.33333}, densityDpi, 160, density, 1.0, screen size, large,
flyer emulator
DisplayMetrics{density=1.0, width=600, height=1024, scaledDensity=1.0, xdpi=160.0, ydpi=160.0}, densityDpi, 160, density, 1.0, screen size, xlarge,
注意“屏幕尺寸”。其他一切都相同,但设备报告“大”和模拟器“xlarge”。有没有办法让模拟器报告“大”?
这是给我输出的java:
DisplayMetrics metrics = new DisplayMetrics();
getWindowManager().getDefaultDisplay().getMetrics(metrics);
int screenLayout = getResources().getConfiguration().screenLayout & Configuration.SCREENLAYOUT_SIZE_MASK;
String screenLayoutStr;
switch (screenLayout){
case Configuration.SCREENLAYOUT_SIZE_SMALL:
screenLayoutStr = "small";
break;
case Configuration.SCREENLAYOUT_SIZE_NORMAL:
screenLayoutStr = "normal";
break;
case Configuration.SCREENLAYOUT_SIZE_LARGE:
screenLayoutStr = "large";
break;
case 4:
screenLayoutStr = "xlarge";
break;
default:
screenLayoutStr = "unknown: " + screenLayout;
}
LogIt.d(this,metrics,"densityDpi",metrics.densityDpi,"density",metrics.density,"screen size",screenLayoutStr);