Android 屏幕宽高,

来源:互联网 发布:c语言送给女友代码 编辑:程序博客网 时间:2024/04/30 11:13

屏幕宽高
这里写图片描述
这里写图片描述

private Dimension getAreaOne(Activity activity){          Dimension dimen = new Dimension();          Display disp = activity.getWindowManager().getDefaultDisplay();          Point outP = new Point();          disp.getSize(outP);          dimen.mWidth = outP.x ;          dimen.mHeight = outP.y;          return dimen;      }      private Dimension getAreaTwo(Activity activity){          Dimension dimen = new Dimension();        Rect outRect = new Rect();        activity.getWindow().getDecorView().getWindowVisibleDisplayFrame(outRect);        System.out.println("top:"+outRect.top +" ; left: "+outRect.left) ;        dimen.mWidth = outRect.width() ;        dimen.mHeight = outRect.height();          return dimen;      }      private Dimension getAreaThree(Activity activity){          Dimension dimen = new Dimension();       // 用户绘制区域           Rect outRect = new Rect();          activity.getWindow().findViewById(Window.ID_ANDROID_CONTENT).getDrawingRect(outRect);          dimen.mWidth = outRect.width() ;          dimen.mHeight = outRect.height();          // end          return dimen;      }  
0 0