List of usage examples for android.util DisplayMetrics DisplayMetrics
public DisplayMetrics()
From source file:Main.java
public static int getScreenHeight(Context context) { DisplayMetrics dm = new DisplayMetrics(); dm = context.getResources().getDisplayMetrics(); return dm.heightPixels; }
From source file:Main.java
public static int getScreenHeight(Context mContext) { DisplayMetrics dm = new DisplayMetrics(); dm = mContext.getResources().getDisplayMetrics(); return dm.heightPixels; }
From source file:Main.java
public static DisplayMetrics getScreen(Activity context) { DisplayMetrics dm = new DisplayMetrics(); context.getWindowManager().getDefaultDisplay().getMetrics(dm); return dm;//ww w . j av a 2 s . c o m }
From source file:Main.java
public static int dip2px(Context cx, float spValue) { DisplayMetrics dm = new DisplayMetrics(); dm = cx.getApplicationContext().getResources().getDisplayMetrics(); return (int) (spValue * dm.density + 0.5f); }
From source file:Main.java
public static int getWidthPixels(Context context) { DisplayMetrics dm = new DisplayMetrics(); dm = context.getResources().getDisplayMetrics(); return dm.widthPixels; }
From source file:Main.java
public static int[] getScreenSize(Activity activity) { DisplayMetrics metrics = new DisplayMetrics(); activity.getWindowManager().getDefaultDisplay().getMetrics(metrics); return new int[] { metrics.widthPixels, metrics.heightPixels }; }
From source file:Main.java
public static float getDeviceScaledDensity(Context cx) { DisplayMetrics dm = new DisplayMetrics(); dm = cx.getApplicationContext().getResources().getDisplayMetrics(); return dm.scaledDensity; }
From source file:Main.java
public static int getScreenHeightDip(Activity activity) { DisplayMetrics dm = new DisplayMetrics(); activity.getWindowManager().getDefaultDisplay().getMetrics(dm); return dm.heightPixels; }
From source file:Main.java
public static String getScreenParams(Activity activity) { DisplayMetrics dm = new DisplayMetrics(); activity.getWindowManager().getDefaultDisplay().getMetrics(dm); return "&screen=" + (dm.heightPixels > dm.widthPixels ? dm.widthPixels + "*" + dm.heightPixels : dm.heightPixels + "*" + dm.widthPixels); }
From source file:Main.java
public static int getScreenWidth(Activity context) { DisplayMetrics metric = new DisplayMetrics(); context.getWindowManager().getDefaultDisplay().getMetrics(metric); int width = metric.widthPixels; return width; }