如何使用code,以确定设备的屏幕尺寸类别(小,中,大,XLARGE)?
问题描述:
有什么方法来确定当前的设备,如小,正常,大,XLARGE的屏幕尺寸的范畴?
Is there any way to determine the category of screen size of the current device, such as small, normal, large, xlarge?
不是密度,但屏幕尺寸。
Not the density, but the screen size.
答
您可以使用Configuration.screenLayout$c$c>位掩码。
You can use the Configuration.screenLayout
bitmask.
例如:
if ((getResources().getConfiguration().screenLayout &
Configuration.SCREENLAYOUT_SIZE_MASK) ==
Configuration.SCREENLAYOUT_SIZE_LARGE) {
// on a large screen device ...
}