判断屏幕尺寸

阅读更多
// support from API 4
final int screenSize = getResources().getConfiguration().screenLayout & Configuration.SCREENLAYOUT_SIZE_MASK;

switch (screenSize) {
	case Configuration.SCREENLAYOUT_SIZE_SMALL:
		break;
	case Configuration.SCREENLAYOUT_SIZE_NORMAL:
		break;
	case Configuration.SCREENLAYOUT_SIZE_LARGE:
		break;
	case Configuration.SCREENLAYOUT_SIZE_XLARGE:
		// support from API 9
		break;
	default:
		break;
}

有一点要注意,必须在AndroidManifest.xml里加上下面的声明

你可能感兴趣的:(android,screensize,mdpi,hdpi,xhdpi)