List of usage examples for android.content Context getResources
public abstract Resources getResources();
From source file:Main.java
public static int getPxSize(Context context, int size) { return size * context.getResources().getDisplayMetrics().densityDpi; }
From source file:Main.java
public static int getDrawableId(Context context, String filename) { return context.getResources().getIdentifier(filename, "drawable", context.getPackageName()); }
From source file:Main.java
public static int getScreenDp(Context context) { final float scale = context.getResources().getDisplayMetrics().density; return (int) (scale + 0.5f); }
From source file:Main.java
public static int[] getDeviceSize(Context context) { DisplayMetrics dm = context.getResources().getDisplayMetrics(); return new int[] { dm.widthPixels, dm.heightPixels }; }
From source file:Main.java
public static Object getStyleableId(Context context, String resName) { return context.getResources().getIdentifier(resName, "styleable", context.getPackageName()); }
From source file:Main.java
public static int getDrawableId(Context context, String resName) { return context.getResources().getIdentifier(resName, "drawable", context.getPackageName()); }
From source file:Main.java
public static final boolean isLandscape(Context context) { return context.getResources().getConfiguration().orientation == Configuration.ORIENTATION_LANDSCAPE; }
From source file:Main.java
/** * Determining the current screen's size related to Large, XLarge or not. * /*from ww w . j a v a 2 s .co m*/ * @param context * The Application Context. * @return boolean Type */ public static boolean isLargeOrXLarge(Context context) { int mask = (context.getResources().getConfiguration().screenLayout & Configuration.SCREENLAYOUT_SIZE_MASK); return (mask == Configuration.SCREENLAYOUT_SIZE_XLARGE) || (mask == Configuration.SCREENLAYOUT_SIZE_LARGE); }
From source file:Main.java
public static int convertPX2DIP(Context context, int px) { float scale = context.getResources().getDisplayMetrics().density; return (int) (px / scale + 0.5f * (px >= 0 ? 1 : -1)); }
From source file:Main.java
public static int getDensity(Context context) { DisplayMetrics dm = context.getResources().getDisplayMetrics(); return dm.densityDpi; }