List of usage examples for android.view Display getMetrics
public void getMetrics(DisplayMetrics outMetrics)
From source file:Main.java
public static int getScreenWidth(Context context) { DisplayMetrics dm = new DisplayMetrics(); WindowManager wm = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE); Display display = wm.getDefaultDisplay(); display.getMetrics(dm); return dm.widthPixels; }
From source file:Main.java
public static int getScreenHeight(Context context) { DisplayMetrics dm = new DisplayMetrics(); WindowManager wm = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE); Display display = wm.getDefaultDisplay(); display.getMetrics(dm); return dm.heightPixels; }
From source file:Main.java
public static DisplayMetrics getScreenSize(Context context) { DisplayMetrics metrics = new DisplayMetrics(); WindowManager wm = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE); Display display = wm.getDefaultDisplay(); display.getMetrics(metrics); return metrics; }
From source file:Main.java
public static float getDeviceDensity(Context context) { DisplayMetrics dMetrics = new DisplayMetrics(); WindowManager wManager = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE); Display display = wManager.getDefaultDisplay(); display.getMetrics(dMetrics); return dMetrics.density; }
From source file:Main.java
public static DisplayMetrics getScreenSize(Context context) { DisplayMetrics dMetrics = new DisplayMetrics(); WindowManager wManager = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE); Display display = wManager.getDefaultDisplay(); display.getMetrics(dMetrics); return dMetrics; }
From source file:Main.java
public static DisplayMetrics getDisplayMetric(Context context) { if (context != null) { WindowManager windowManager = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE); DisplayMetrics displayMetrics = new DisplayMetrics(); Display display = windowManager.getDefaultDisplay(); display.getMetrics(displayMetrics); return displayMetrics; }//w w w . j a va 2 s . c om return null; }
From source file:Main.java
private static DisplayMetrics getDisplayMetrics(Activity activity) { DisplayMetrics metrics = new DisplayMetrics(); Display display = activity.getWindowManager().getDefaultDisplay(); display.getMetrics(metrics); return metrics; }
From source file:Main.java
private static DisplayMetrics getDisplayMetrics(final Activity activity) { final DisplayMetrics metrics = new DisplayMetrics(); final Display display = activity.getWindowManager().getDefaultDisplay(); display.getMetrics(metrics); return metrics; }
From source file:Main.java
public static int getDpi(Activity activity) { WindowManager wm = activity.getWindowManager(); //wm = (WindowManager) getSystemService(Context.WINDOW_SERVICE); Display dp = wm.getDefaultDisplay(); DisplayMetrics dm = new DisplayMetrics(); dp.getMetrics(dm); return dm.densityDpi; }
From source file:Main.java
public static float getDPI() { if (sContext != null) { DisplayMetrics metrics = new DisplayMetrics(); WindowManager wm = ((Activity) sContext).getWindowManager(); if (wm != null) { Display d = wm.getDefaultDisplay(); if (d != null) { d.getMetrics(metrics); return (metrics.density * 160.0f); }//from w w w . ja v a 2 s. com } } return -1.0f; }