如何知道android中不同布局的屏幕大小

如何知道android中不同布局的屏幕大小,android,Android,我正在开发一个应用程序,当它是一个手机时,我不想要蚂蚁标签式的动作栏,当它是一个平板电脑(英寸及以上)时,我想要标签式的动作栏。有什么想法吗 提前感谢您将此代码复制并粘贴到您的主要活动中,当应用程序启动时,它将显示设备的屏幕大小类别 int screenSize = getResources().getConfiguration().screenLayout & Configuration.SCREENLAYOUT_SIZE_MASK; String toastMsg;

我正在开发一个应用程序,当它是一个手机时,我不想要蚂蚁标签式的动作栏,当它是一个平板电脑(英寸及以上)时,我想要标签式的动作栏。有什么想法吗


提前感谢您

将此代码复制并粘贴到您的主要活动中,当应用程序启动时,它将显示设备的屏幕大小类别

int screenSize = getResources().getConfiguration().screenLayout &
        Configuration.SCREENLAYOUT_SIZE_MASK;

String toastMsg;
switch(screenSize) {
    case Configuration.SCREENLAYOUT_SIZE_LARGE:
        toastMsg = "Large screen";
        break;
    case Configuration.SCREENLAYOUT_SIZE_NORMAL:
        toastMsg = "Normal screen";
        break;
    case Configuration.SCREENLAYOUT_SIZE_SMALL:
        toastMsg = "Small screen";
        break;
    default:
        toastMsg = "Screen size is neither large, normal or small";
}
Toast.makeText(this, toastMsg, Toast.LENGTH_LONG).show();
或获取高度和宽度:

Display display = getWindowManager().getDefaultDisplay();
Point size = new Point();
display.getSize(size);
int width = size.x;
int height = size.y;
在引入getSize之前(在API级别13中)


谢谢但我是否想要更好地控制屏幕大小?喜欢屏幕限定符吗?(例如sw600dp)
Display display = getWindowManager().getDefaultDisplay(); 
int width = display.getWidth();  // deprecated
int height = display.getHeight();  // deprecated