List of usage examples for android.content Context getResources
public abstract Resources getResources();
From source file:Main.java
public static int getWidth(Context context) { int screenWidth = context.getResources().getDisplayMetrics().widthPixels; return screenWidth; }
From source file:Main.java
public static int getColor(Context context, int resId) { return context.getResources().getColor(resId); }
From source file:Main.java
public static int getId(Context context, String name) { return context.getResources().getIdentifier(name, "id", context.getPackageName()); }
From source file:Main.java
public static int getDimens(Context context, int resId) { return context.getResources().getDimensionPixelSize(resId); }
From source file:Main.java
public static int getPixels(float dps, Context context) { float scale = context.getResources().getDisplayMetrics().density; int pixels = (int) (dps * scale + 0.5f); return pixels; }
From source file:Main.java
public static int getDimenId(Context context, String name) { return context.getResources().getIdentifier(name, "dimen", context.getPackageName()); }
From source file:Main.java
public static float dpFromPx(Context context, float f) { return f / context.getResources().getDisplayMetrics().density; }
From source file:Main.java
public static int colorForKeycode(Context c, int keycode) { return c.getResources().getColor(colors[keycode % colors.length]); }
From source file:Main.java
public static int dimen2px(Context context, int dimRes) { return context.getResources().getDimensionPixelSize(dimRes); }
From source file:Main.java
public static int getColorId(Context context, String name) { return context.getResources().getIdentifier(name, "color", context.getPackageName()); }