List of usage examples for android.content Context getResources
public abstract Resources getResources();
From source file:Main.java
public static int getHeight(Context context) { DisplayMetrics dm = context.getResources().getDisplayMetrics(); return dm.heightPixels; }
From source file:Main.java
public static int dimen2px(Context context, int dimenId) { int a = context.getResources().getDimensionPixelSize(dimenId); return a;// w ww . ja v a2 s . co m }
From source file:Main.java
public static int getScreenWidth(Context context) { DisplayMetrics dm = context.getResources().getDisplayMetrics(); int w_screen = dm.widthPixels; return w_screen; }
From source file:Main.java
public static int getResId(Context context, String filename) { return context.getResources().getIdentifier(filename, "raw", context.getPackageName()); }
From source file:Main.java
public static String deviceResolution(Context c) { DisplayMetrics metrics = c.getResources().getDisplayMetrics(); return String.valueOf(metrics.widthPixels) + "x" + metrics.heightPixels; }
From source file:Main.java
public static Drawable getDrawable(Context context, int drawableId) { return context.getResources().getDrawable(drawableId); }
From source file:Main.java
public static int dp2px(Context context, int dip) { float scale = context.getResources().getDisplayMetrics().density; return (int) (dip * scale + 0.5f * (dip >= 0 ? 1 : -1)); }
From source file:Main.java
public static int getDisplayWidth(Context context) { DisplayMetrics dm = context.getResources().getDisplayMetrics(); return dm.widthPixels; }
From source file:Main.java
public static int dp2px(Context context, float dp) { return (int) (context.getResources().getDisplayMetrics().density * dp + 0.5f); }
From source file:Main.java
public static float getScaledDensity(Context context) { DisplayMetrics dm = context.getResources().getDisplayMetrics(); return dm.scaledDensity; }