List of usage examples for android.content Context getResources
public abstract Resources getResources();
From source file:Main.java
public static int px2dip(float pxValue, Context context) { float scale = context.getResources().getDisplayMetrics().density; return (int) (pxValue / scale + 0.5f); }
From source file:Main.java
public static int getDrawableID(Context context, String key) { return context.getResources().getIdentifier(key, "drawable", context.getPackageName()); }
From source file:Main.java
public static int getID(Context context, String key) { return context.getResources().getIdentifier(key, "id", context.getPackageName()); }
From source file:Main.java
public static String getStringFromResource(Context context, int resId) { return context.getResources().getString(resId); }
From source file:Main.java
public static int getLayoutID(Context context, String key) { return context.getResources().getIdentifier(key, "layout", context.getPackageName()); }
From source file:Main.java
/** * returns true if screen is Xlarge so restricts orientation based on that * @param context/*from w ww. j av a2s. c o m*/ * @return */ public static boolean isScreenXLarge(Context context) { return (context.getResources().getConfiguration().screenLayout & Configuration.SCREENLAYOUT_SIZE_MASK) >= (Configuration.SCREENLAYOUT_SIZE_LARGE); }
From source file:Main.java
public static int dpToPx(int dp, Context context) { float density = context.getResources().getDisplayMetrics().density; return Math.round((float) dp * density); }
From source file:Main.java
public static int getStringID(Context context, String key) { return context.getResources().getIdentifier(key, "string", context.getPackageName()); }
From source file:Main.java
public static Drawable getTintedDrawable(int resDrawable, int tintColor, Context context) { Drawable d = context.getResources().getDrawable(resDrawable); // ToDo: use non-deprecated method d.setColorFilter(tintColor, PorterDuff.Mode.SRC_IN); return d;//w w w . java 2 s .c o m }
From source file:Main.java
private static int dpToPx(int dp, Context context) { float density = context.getResources().getDisplayMetrics().density; return Math.round((float) dp * density); }