0

有没有办法测试安卓设备的分辨率?

4

2 回答 2

4

在任何测试函数中,您都可以编写以下代码:

    Activity ACT = getActivity();


    Display display = ACT.getWindowManager().getDefaultDisplay();
    Point size = new Point();
    display.getSize(size);
    int width = size.x;
    int height = size.y;

或者如果 API<13

Display display = getWindowManager().getDefaultDisplay(); 
int width = display.getWidth(); 
int height = display.getHeight(); 
于 2013-01-07T11:42:39.613 回答
0

希望得到帮助:[如果您计划为手机/平板电脑运行相同的测试代码]

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
}
于 2013-10-03T09:30:37.347 回答