List of usage examples for android.util DisplayMetrics DisplayMetrics
public DisplayMetrics()
From source file:Main.java
public static int getDeviceDPI(Context context) { DisplayMetrics metrics = new DisplayMetrics(); WindowManager mgr = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE); mgr.getDefaultDisplay().getMetrics(metrics); return metrics.densityDpi; }
From source file:Main.java
public static int getHeight(Activity context) { DisplayMetrics dm = new DisplayMetrics(); context.getWindowManager().getDefaultDisplay().getMetrics(dm); return dm.heightPixels; }
From source file:Main.java
public static int getScreenWidth(Context context) { DisplayMetrics metrics = new DisplayMetrics(); WindowManager wm = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE); wm.getDefaultDisplay().getMetrics(metrics); return metrics.widthPixels; }
From source file:Main.java
public static int getScreenHeight(Activity context) { DisplayMetrics dm = new DisplayMetrics(); context.getWindowManager().getDefaultDisplay().getMetrics(dm); int mScreenHeight = dm.heightPixels; return mScreenHeight; }
From source file:Main.java
public static DisplayMetrics getScreenInfo(Context context) { DisplayMetrics dm = new DisplayMetrics(); ((Activity) context).getWindowManager().getDefaultDisplay().getMetrics(dm); return dm;/*from w w w. j a va 2 s . c o m*/ }
From source file:Main.java
public static int getDeviceHeight(Context context) { DisplayMetrics dm = new DisplayMetrics(); WindowManager manager = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE); manager.getDefaultDisplay().getMetrics(dm); return dm.heightPixels; }
From source file:Main.java
public static float getDensity(Context context) { DisplayMetrics dm = new DisplayMetrics(); dm = context.getApplicationContext().getResources().getDisplayMetrics(); float density = dm.density; return density; }
From source file:Main.java
public static DisplayMetrics getDisplayMetrics(Context context) { DisplayMetrics dm = new DisplayMetrics(); ((Activity) context).getWindowManager().getDefaultDisplay().getMetrics(dm); return dm;//from ww w . ja v a2s . co m }
From source file:Main.java
public static int getScreenWidth(Context context) { DisplayMetrics displaymetrics = new DisplayMetrics(); ((Activity) context).getWindowManager().getDefaultDisplay().getMetrics(displaymetrics); int width = displaymetrics.widthPixels; return width; }
From source file:Main.java
public static int getWindowHeight(Activity context) { DisplayMetrics metric = new DisplayMetrics(); context.getWindowManager().getDefaultDisplay().getMetrics(metric); return metric.heightPixels; }