Android获取屏幕宽和高

android获取屏幕的高度和宽度用到WindowManager这个类,两种方法:
 
1、WindowManager wm = (WindowManager) getContext()
                    .getSystemService(Context.WINDOW_SERVICE);
 
     int width = wm.getDefaultDisplay().getWidth();
     int height = wm.getDefaultDisplay().getHeight();
 
2、WindowManager wm = this.getWindowManager();
 
     int width = wm.getDefaultDisplay().getWidth();
     int height = wm.getDefaultDisplay().getHeight();
posted @ 2016-07-14 10:33  DarrenChan陈驰  阅读(233)  评论(0编辑  收藏  举报
Live2D