List of usage examples for android.util DisplayMetrics DisplayMetrics
public DisplayMetrics()
From source file:Main.java
public static DisplayMetrics getScreenDisplayMetrics(Context context) { DisplayMetrics dm = new DisplayMetrics(); WindowManager wm = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE); wm.getDefaultDisplay().getMetrics(dm); return dm;/* w w w . j av a 2 s . c o m*/ }
From source file:Main.java
public static DisplayMetrics getScreenDimention(Context mContext) { DisplayMetrics displaymetrics = new DisplayMetrics(); ((Activity) mContext).getWindowManager().getDefaultDisplay().getMetrics(displaymetrics); return displaymetrics; }
From source file:Main.java
public static int dpToPixel(Activity activity, float dp) { DisplayMetrics metrics = new DisplayMetrics(); activity.getWindowManager().getDefaultDisplay().getMetrics(metrics); return (int) (metrics.density * dp); }
From source file:Main.java
public static int getScreenHeight(Context act) { final DisplayMetrics displayMetrics = new DisplayMetrics(); WindowManager wm = (WindowManager) act.getSystemService(Context.WINDOW_SERVICE); wm.getDefaultDisplay().getMetrics(displayMetrics); return displayMetrics.heightPixels; }
From source file:Main.java
public static Integer getDisplayWidth(Context context) { DisplayMetrics displayMetrics = new DisplayMetrics(); WindowManager windowmanager = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE); windowmanager.getDefaultDisplay().getMetrics(displayMetrics); return displayMetrics.widthPixels; }
From source file:Main.java
public static DisplayMetrics getScreenMetrics(Activity mActivity) { DisplayMetrics metric = new DisplayMetrics(); mActivity.getWindowManager().getDefaultDisplay().getMetrics(metric); return metric; }
From source file:Main.java
public static int getScreenWidth(Context act) { final DisplayMetrics displayMetrics = new DisplayMetrics(); WindowManager wm = (WindowManager) act.getSystemService(Context.WINDOW_SERVICE); wm.getDefaultDisplay().getMetrics(displayMetrics); return displayMetrics.widthPixels; }
From source file:Main.java
public static DisplayMetrics getScreenSize(Activity activity) { DisplayMetrics result = null;//from w w w . j av a2s . co m try { result = new DisplayMetrics(); activity.getWindowManager().getDefaultDisplay().getMetrics(result); } catch (Exception e) { } return result; }
From source file:Main.java
public static float getScreenDPI(Context context) { final DisplayMetrics displayMetrics = new DisplayMetrics(); WindowManager wm = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE); wm.getDefaultDisplay().getMetrics(displayMetrics); return (float) displayMetrics.densityDpi; }
From source file:Main.java
public static int getDeviceWidth(Context context) { int width = 0; DisplayMetrics dm = new DisplayMetrics(); WindowManager wm = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE); wm.getDefaultDisplay().getMetrics(dm); width = dm.widthPixels;/* w w w .j ava 2 s. com*/ return width; }