List of usage examples for android.content Context getResources
public abstract Resources getResources();
From source file:Main.java
public static final int px2dp(Context context, float pxValue) { float scale = context.getResources().getDisplayMetrics().density; return (int) (pxValue / scale + 0.5); }
From source file:Main.java
public static String getStringOfRes(Context context, @StringRes int res) { return context.getResources().getString(res); }
From source file:Main.java
public static float getPixels(Context context, float dp) { Resources r = context.getResources(); return TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, dp, r.getDisplayMetrics()); }
From source file:Main.java
public static boolean isOriatationPortrait(Context context) { return context.getResources().getConfiguration().orientation == Configuration.ORIENTATION_PORTRAIT; }
From source file:Main.java
public static float pixelToDP(Context context, float val) { float density = context.getResources().getDisplayMetrics().density; return val / density; }
From source file:Main.java
public static int getHeightScreen(Context context) { DisplayMetrics metric = context.getResources().getDisplayMetrics(); int height = metric.heightPixels; return height; }
From source file:Main.java
static String getStrng(Context context, int resId) { return context.getResources().getString(resId); }
From source file:Main.java
public static final int dp2px(Context context, float dpValue) { float scale = context.getResources().getDisplayMetrics().density; return (int) (dpValue * scale + 0.5f); }
From source file:Main.java
public static int getPixelsInt(Context context, float dp) { Resources r = context.getResources(); return Math.round(TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, dp, r.getDisplayMetrics())); }
From source file:Main.java
public static int px2dp(Context context, int pxValue) { float density = context.getResources().getDisplayMetrics().density; return (int) (pxValue / density + 0.5); }