android 获取屏幕的长和宽

 
     DisplayMetrics dm = new DisplayMetrics();
      PicCenterItem.this.getWindowManager().getDefaultDisplay().getMetrics(dm);
      int mWidth = dm.widthPixels;
      int mHeight = dm.heightPixels;
     
      if (mHeight > mWidth){
       //竖屏
      }else{
       //横屏
      }

说明:
PicCenterItem:当前类

你可能感兴趣的:(android,获取屏幕的长和宽)