如何使用code,以确定设备的屏幕尺寸类别(小,中,大,XLARGE)? [英] How to determine device screen size category (small, normal, large, xlarge) using code?

查看:344
本文介绍了如何使用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.

推荐答案

您可以使用<一个href="http://developer.android.com/reference/android/content/res/Configuration.html#screenLayout"><$c$c>Configuration.screenLayout位掩码。

You can use the Configuration.screenLayout bitmask.

例如:

if ((getResources().getConfiguration().screenLayout & 
    Configuration.SCREENLAYOUT_SIZE_MASK) == 
        Configuration.SCREENLAYOUT_SIZE_LARGE) {
    // on a large screen device ...

}

这篇关于如何使用code,以确定设备的屏幕尺寸类别(小,中,大,XLARGE)?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆