Android 屏幕大小和设备方向
我正在从事与普通屏幕尺寸检测和设备定位相关的任务 是否有任何内置的解决方案可以在运行时检测屏幕大小(正常、大、xlarge),而无需向资源文件添加内容 检查设备方向 屏幕尺寸检测Android 屏幕大小和设备方向,android,screen-orientation,Android,Screen Orientation,我正在从事与普通屏幕尺寸检测和设备定位相关的任务 是否有任何内置的解决方案可以在运行时检测屏幕大小(正常、大、xlarge),而无需向资源文件添加内容 检查设备方向 屏幕尺寸检测 为什么你需要用谷歌的屏幕大小来计算屏幕大小? int orientation = getResources().getConfiguration().orientation; if(orientation == Configuration.ORIENTATION_PORTRAIT){ }else i
为什么你需要用谷歌的屏幕大小来计算屏幕大小?
int orientation = getResources().getConfiguration().orientation;
if(orientation == Configuration.ORIENTATION_PORTRAIT){
}else if(orientation == Configuration.ORIENTATION_LANDSCAPE){}
if ((getResources().getConfiguration().screenLayout & Configuration.SCREENLAYOUT_SIZE_MASK) == Configuration.SCREENLAYOUT_SIZE_LARGE) { // Large screen
} else if ((getResources().getConfiguration().screenLayout & Configuration.SCREENLAYOUT_SIZE_MASK) == Configuration.SCREENLAYOUT_SIZE_NORMAL) { //Normal sized screen
} else if ((getResources().getConfiguration().screenLayout & Configuration.SCREENLAYOUT_SIZE_MASK) == Configuration.SCREENLAYOUT_SIZE_SMALL) {//Small sized screen
} else if ((getResources().getConfiguration().screenLayout & Configuration.SCREENLAYOUT_SIZE_MASK) == Configuration.SCREENLAYOUT_SIZE_XLARGE) {//XLarge sized screen}