List of usage examples for android.content Context getResources
public abstract Resources getResources();
From source file:Main.java
public static Point getScreenPoint(Context ctx) { DisplayMetrics dm = ctx.getResources().getDisplayMetrics(); Point point = new Point(dm.widthPixels, dm.heightPixels); return point; }
From source file:Main.java
/** * Converts a given dip-value into a pixel-value * * @param dip - the dip value to convert * @param context - the application context * @return the converted pixel value// w ww .jav a2 s .c om */ public static int dipToPx(int dip, Context context) { Resources r = context.getResources(); return (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, dip, r.getDisplayMetrics()); }
From source file:Main.java
public static float getDimensionInPx(Context context, @DimenRes int id) { return context.getResources().getDimension(id); }
From source file:Main.java
public static int getScreenHeight(Context context) { Resources resources = context.getResources(); DisplayMetrics metrics = resources.getDisplayMetrics(); return metrics.heightPixels; }
From source file:Main.java
public static int dip2px(Context context, float dipValue) { float m = context.getResources().getDisplayMetrics().density; return (int) (dipValue * m + 0.5f); }
From source file:Main.java
public static int dp2px(Context ctx, float dp) { float density = ctx.getResources().getDisplayMetrics().density; int px = (int) (dp * density + 0.5f);// 4.9->5 4.4->4 return px;// w ww .j a v a 2s . c om }
From source file:Main.java
public static int dp2px(Context context, float dp) { float density = context.getResources().getDisplayMetrics().density; return Math.round(dp * density); }
From source file:Main.java
public static float px2dip(Context context, int pxvalue) { float scale = context.getResources().getDisplayMetrics().density; return pxvalue / scale; }
From source file:Main.java
public static int getStatusBarHeight(Context context) { return (int) Math.ceil(25 * context.getResources().getDisplayMetrics().density); }
From source file:Main.java
public static InputStream getInputStream(Context context, int rawResId) { return context.getResources().openRawResource(rawResId); }