如何让你的Android设备的屏幕分辨率..?
我拿到Android手机的分辨率..?
如果是的话那么如何..?
它会替我真正有用的..
谢谢。
Can i get resolution of android phone..?
if yes then how..?
it will really helpful for me..
Thank you..
如果你想在像素的显示尺寸,你可以使用的getSize:
If you want the display dimensions in pixels you can use getSize:
Display display = getWindowManager().getDefaultDisplay();
Point size = new Point();
display.getSize(size);
int width = size.x;
int height = size.y;
该方法被引入Android的API 13,所以如果你想获得previous的API显示的指标是:
This method was introduced in Android API 13, so if you want to get display metrics for previous APIs use:
DisplayMetrics displaymetrics = new DisplayMetrics();
getWindowManager().getDefaultDisplay().getMetrics(displaymetrics);
int height = displaymetrics.heightPixels;
int wwidth = displaymetrics.widthPixels;
如果你不是一个活动,你可以通过 WINDOW_SERVICE
默认显示。此外,一定要你的minSdkVersion设置为至少4在AndroidManifest.xml中,使调用display.getWidth()。
If you're not in an Activity, you can get the default Display via WINDOW_SERVICE
. Also be sure to set your minSdkVersion to at least 4 in AndroidManifest.xml to enable calls to display.getWidth().
WindowManager wm = (WindowManager) ctx.getSystemService(Context.WINDOW_SERVICE);
Display display = wm.getDefaultDisplay();
int width = display.getWidth(); // deprecated
int height = display.getHeight(); // deprecated
编辑:PhoneGap的
使用下面找出显示器的像素大小
Use the following to figure out the display size in pixels
function getDeviceDimention() {
console.log("Device Dimention using PhoneGap");
console.log("Width = " + window.innerWidth);
console.log("Height = " + window.innerHeight);
}