List of usage examples for android.util DisplayMetrics DisplayMetrics
public DisplayMetrics()
From source file:Main.java
/** * calculate the display parameters//from ww w .ja v a2s . co m * * @param activity * @return */ public static DisplayMetrics getDisplayMetrics(Activity activity) { DisplayMetrics displaymetrics = new DisplayMetrics(); activity.getWindowManager().getDefaultDisplay().getMetrics(displaymetrics); return displaymetrics; }
From source file:Main.java
public static int getWidth(Context context) { WindowManager wm = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE); DisplayMetrics outMetrics = new DisplayMetrics(); wm.getDefaultDisplay().getMetrics(outMetrics); return outMetrics.widthPixels; }
From source file:Main.java
public static Point getScreenResolution(Activity activity) { // get the layout width/height DisplayMetrics dm = new DisplayMetrics(); activity.getWindowManager().getDefaultDisplay().getMetrics(dm); // create point Point p = new Point(); p.set(dm.widthPixels, dm.heightPixels); return p;/* w w w . j av a 2s . com*/ }
From source file:Main.java
public static int getScreenHeight(Context context) { WindowManager wm = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE); DisplayMetrics metrics = new DisplayMetrics(); wm.getDefaultDisplay().getMetrics(metrics); return metrics.heightPixels; }
From source file:Main.java
public static int getWindowHeigh(Context context) { WindowManager wm = (WindowManager) (context.getSystemService(Context.WINDOW_SERVICE)); DisplayMetrics dm = new DisplayMetrics(); wm.getDefaultDisplay().getMetrics(dm); int mScreenHeigh = dm.heightPixels; return mScreenHeigh; }
From source file:Main.java
public static int getWindowWidth(Context context) { WindowManager wm = (WindowManager) (context.getSystemService(Context.WINDOW_SERVICE)); DisplayMetrics dm = new DisplayMetrics(); wm.getDefaultDisplay().getMetrics(dm); return dm.widthPixels; }
From source file:Main.java
public static int getDisplayWidth(Context context) { WindowManager wm = (WindowManager) (context.getSystemService(Context.WINDOW_SERVICE)); DisplayMetrics dm = new DisplayMetrics(); wm.getDefaultDisplay().getMetrics(dm); int mScreenWidth = dm.widthPixels; return mScreenWidth; }
From source file:Main.java
public static int getScreenWidth(Context context) { WindowManager manager = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE); DisplayMetrics dm = new DisplayMetrics(); manager.getDefaultDisplay().getMetrics(dm); return dm.widthPixels; }
From source file:Main.java
public static int getWindowHeight(Context context) { WindowManager wm = (WindowManager) (context.getSystemService(Context.WINDOW_SERVICE)); DisplayMetrics dm = new DisplayMetrics(); wm.getDefaultDisplay().getMetrics(dm); return dm.heightPixels; }
From source file:Main.java
public static int getScreenHeight(Context context) { WindowManager manager = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE); DisplayMetrics dm = new DisplayMetrics(); manager.getDefaultDisplay().getMetrics(dm); return dm.heightPixels; }