android获取屏幕分辨率实现

DisplayMetrics dm = new DisplayMetrics();
  WindowManager windowMgr = (WindowManager)getApplicationContext().getSystemService(Context.WINDOW_SERVICE);
  windowMgr.getDefaultDisplay().getMetrics(dm);
  int width = dm.widthPixels;
  int height = dm.heightPixels;
  Toast.makeText(getApplicationContext(), "手机屏幕分辨率:"+width+"*"+height, Toast.LENGTH_LONG).show();

你可能感兴趣的:(android)