现在的位置: 首页 > 综合 > 正文

android屏幕

2018年05月01日 ⁄ 综合 ⁄ 共 591字 ⁄ 字号 评论关闭

// 屏幕方面切换时获得方向

  if(this.getResources().getConfiguration().orientation ==Configuration.ORIENTATION_LANDSCAPE) {

  setTitle("landscape");

  }

  if(this.getResources().getConfiguration().orientation ==Configuration.ORIENTATION_PORTRAIT) {

  setTitle("portrait");

  }

  // 获得屏幕大小1

 WindowManager manager = getWindowManager();

  intwidth = manager.getDefaultDisplay().getWidth();

  intheight = manager.getDefaultDisplay().getHeight();

  // 获得屏幕大小2

 DisplayMetrics dMetrics = new DisplayMetrics();

 getWindowManager().getDefaultDisplay().getMetrics(dMetrics);

  intscreenWidth = dMetrics.widthPixels;

  intscreenHeight = dMetrics.heightPixels;

抱歉!评论已关闭.