Android小技巧/获取屏幕宽高

来源:互联网 发布:华为java编码规范考试 编辑:程序博客网 时间:2024/04/30 08:06
int width=0;    WindowManager wm = (WindowManager) mContext.getSystemService(Context.WINDOW_SERVICE);    Display display = wm.getDefaultDisplay();    if(Build.VERSION.SDK_INT>Build.VERSION_CODES.HONEYCOMB){                           Point size = new Point();        display.getSize(size);        width = size.x;    }    else{        width = display.getWidth();  // deprecated    }