public static intSCREEN_WIDTH= -1;
public static intSCREEN_HEIGHT= -1;
public static floatDIMEN_RATE= -1.0F;
public static intDIMEN_DPI= -1;
public void getScreenSize() {
WindowManager windowManager = (WindowManager)this.getSystemService(Context.WINDOW_SERVICE);
DisplayMetrics dm = new DisplayMetrics();
Displaydisplay = windowManager.getDefaultDisplay();
display.getMetrics(dm);
DIMEN_RATE= dm.density/1.0F;
DIMEN_DPI= dm.densityDpi;
SCREEN_WIDTH= dm.widthPixels;
SCREEN_HEIGHT= dm.heightPixels;
if(SCREEN_WIDTH>SCREEN_HEIGHT) {
int t =SCREEN_HEIGHT;
SCREEN_HEIGHT=SCREEN_WIDTH;
SCREEN_WIDTH= t;
}
}
网友评论