List of usage examples for android.content Context getResources
public abstract Resources getResources();
From source file:Main.java
public static int getDeviceDpi(Context context) { DisplayMetrics dm = context.getResources().getDisplayMetrics(); return dm.densityDpi; }
From source file:Main.java
public static int getId(Context context, String resName) { return context.getResources().getIdentifier(resName, "id", context.getPackageName()); }
From source file:Main.java
public static float dp2px(Context context, float dp) { return dp * context.getResources().getDisplayMetrics().density; }
From source file:Main.java
public static int getColorId(Context context, String resName) { return context.getResources().getIdentifier(resName, "color", context.getPackageName()); }
From source file:Main.java
public static int dp2px(float value, Context context) { final float scale = context.getResources().getDisplayMetrics().densityDpi; return (int) (value * (scale / 160) + 0.5f); }
From source file:Main.java
public static int getDrawableResId(Context context, String name) { return context.getResources().getIdentifier(name, android.R.drawable.class.getSimpleName(), context.getPackageName());/*from w w w .j a v a 2 s . co m*/ }
From source file:Main.java
public static int sp2px(float spValue, Context context) { final float scale = context.getResources().getDisplayMetrics().density; return (int) (spValue * scale + 0.5f); }
From source file:Main.java
public static float getDpSize(Context context, float dpValue) { return context.getResources().getDisplayMetrics().density * dpValue; }
From source file:Main.java
public static int dip2px(float dpValue, Context context) { final float scale = context.getResources().getDisplayMetrics().density; return (int) (dpValue * scale + 0.5f); }
From source file:Main.java
public static float pxFromDp(Context context, float dp) { return dp * context.getResources().getDisplayMetrics().density; }