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

Android获取荧幕高宽

热度:52   发布时间:2016-05-01 16:00:33.0
Android获取屏幕高宽

(1)int width,height;

??WindowManager windowManager = getWindowManager();
??Display display = windowManager.getDefaultDisplay();
??screenWidth = display.getWidth();
??screenHeight = display.getHeight();
?(2)int width,height;

??????? DisplayMetrics displayMetrics = new DisplayMetrics();??
??????? this.getWindowManager().getDefaultDisplay().getMetrics(displayMetrics);???
??????? height = displayMetrics.heightPixels;???
??????? width = displayMetrics.widthPixels;

  相关解决方案