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;

已标记关键词 清除标记
©️2020 CSDN 皮肤主题: 大白 设计师:CSDN官方博客 返回首页