List of usage examples for android.util TypedValue applyDimension
public static float applyDimension(int unit, float value, DisplayMetrics metrics)
From source file:Main.java
private static boolean canFit(Resources res, int adWidth) { int adWidthPx = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, adWidth, res.getDisplayMetrics());/*from w w w . ja v a2s .com*/ DisplayMetrics metrics = res.getDisplayMetrics(); return metrics.widthPixels >= adWidthPx; }
From source file:Main.java
public static int dpToPx(int dp, Context ctx) { Resources r = ctx.getResources(); return (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, dp, r.getDisplayMetrics()); }
From source file:Main.java
/** * @param context/*from w w w. j av a2 s. c om*/ * @param dp * @return */ public static int dp2px(Context context, int dp) { return (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, dp, context.getResources().getDisplayMetrics()); }
From source file:Main.java
public static int ConvertToPx(Context c, int dip) { Resources r = c.getResources(); float px = TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, dip, r.getDisplayMetrics()); return (int) px; }
From source file:Main.java
public static int dpToPx(Context context, int dp) { Resources r = context.getResources(); float px = TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, dp, r.getDisplayMetrics()); return (int) px; }
From source file:Main.java
public static int dipToPx(Context context, int dip) { Resources r = context.getResources(); return (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, dip, r.getDisplayMetrics()); }
From source file:Main.java
public static int getPixels(Context c, int dipValue) { Resources r = c.getResources(); int px = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, dipValue, r.getDisplayMetrics()); return px;/* w w w .j a va 2 s.c o m*/ }
From source file:Main.java
public static int convertDipToPx(Context context, int dp) { Resources r = context.getResources(); float px = TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, dp, r.getDisplayMetrics()); return (int) px; }
From source file:Main.java
public static int dip2px(Context context, float dpValue) { Resources r = context.getResources(); float px = TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, dpValue, r.getDisplayMetrics()); return (int) px; }
From source file:Main.java
public static int convertDpToPixel(Context context, int dp) { Resources r = context.getResources(); float px = TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, dp, r.getDisplayMetrics()); return Math.round(px); }