List of usage examples for android.util TypedValue applyDimension
public static float applyDimension(int unit, float value, DisplayMetrics metrics)
From source file:Main.java
/** * dp to pixels// w w w . j a v a 2 s. co m * @param val dp * @return pixels */ public static int dpToPx(float val) { return (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, val, _dm); }
From source file:Main.java
/** * px = dp * (dpi / 160)/*from w w w.j a va 2s . co m*/ * * @param ctx * @param dip * @return */ public static int dipToPX(final Context ctx, float dip) { return (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, dip, ctx.getResources().getDisplayMetrics()); }
From source file:Main.java
public static int dipToPixels(Context applicationContext, int dip) { Resources r = applicationContext.getResources(); float px = TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, dip, r.getDisplayMetrics()); return (int) px; }
From source file:Main.java
public static float dipToPixels(Context context, float dipValue) { DisplayMetrics metrics = context.getResources().getDisplayMetrics(); return TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, dipValue, metrics); }
From source file:Main.java
public static int dipToPix(Context context, float dipValue) { DisplayMetrics metrics = context.getResources().getDisplayMetrics(); return (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, dipValue, metrics); }
From source file:Main.java
public static int sp2px(Context context, float spVal) { DisplayMetrics displayMetrics = context.getResources().getDisplayMetrics(); return (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_SP, spVal, displayMetrics); }
From source file:Main.java
public static int dp2px(Context context, float dpVal) { DisplayMetrics displayMetrics = context.getResources().getDisplayMetrics(); return (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, dpVal, displayMetrics); }
From source file:Main.java
public static float dpToPx(Resources res, float dp) { return TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, dp, res.getDisplayMetrics()); }
From source file:Main.java
/** * Convert dip to pixels//w w w .j ava2 s . c o m * * param size The size to be converted * * @author Melvin Lobo */ public static float d2x(Context context, int size) { return TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, size, context.getResources().getDisplayMetrics()); }
From source file:Main.java
/** * Does conversion from dp to px./* w w w .j av a 2 s . c om*/ * @param resources * @param dp * @return float equivalent of pixels */ public static float dpToPx(Resources resources, int dp) { return TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, dp, resources.getDisplayMetrics()); }