当前位置: 代码迷 >> Android >> Android 取得屏幕的宽高
  详细解决方案

Android 取得屏幕的宽高

热度:17   发布时间:2016-04-27 22:02:04.0
Android 获得屏幕的宽高
 private DisplayMetrics getWithAndHeight(Context context){        DisplayMetrics displayMetrics = new DisplayMetrics();        WindowManager windowManager = (WindowManager)context.getSystemService(Context.WINDOW_SERVICE);        windowManager.getDefaultDisplay().getMetrics(displayMetrics);        return displayMetrics; }        //get in the function where you need        DisplayMetrics displayMetrics = getWithAndHeight(getActivity());        widthPixels = displayMetrics.widthPixels;        heightPixels = displayMetrics.heightPixels;
  相关解决方案