有没有一种方法可以测试android设备的分辨率?
In any test function you can write following code:
Activity ACT = getActivity();
Display display = ACT.getWindowManager().getDefaultDisplay();
Point size = new Point();
display.getSize(size);
int width = size.x;
int height = size.y;
or if API<13
Display display = getWindowManager().getDefaultDisplay();
int width = display.getWidth();
int height = display.getHeight();
Hope this Help : [If ur planning to run same test code for Phone/Tablet]
Configuration mConfig = mContext.getResources().getConfiguration();
// checking for XLarge screen ...U can also check for Large screen similarly
if ((mConfig.screenLayout & Configuration.SCREENLAYOUT_SIZE_XLARGE) == Configuration.SCREENLAYOUT_SIZE_XLARGE) {
Log.i("TABLET MODE");
// Do ur actions for Tablet
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.