List of usage examples for android.util TypedValue COMPLEX_UNIT_DIP
int COMPLEX_UNIT_DIP
To view the source code for android.util TypedValue COMPLEX_UNIT_DIP.
Click Source Link
From source file:Main.java
/** * Convert Dp to Pixel// w w w.ja v a 2s . co m */ public static int dpToPx(float dp, Resources resources) { float px = TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, dp, resources.getDisplayMetrics()); return (int) px; }
From source file:Main.java
public static int dipToPix(Context context, int dip) { int size = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, dip, context.getResources().getDisplayMetrics()); return size;/*from w ww .ja v a 2 s . c o m*/ }
From source file:Main.java
public static int convertDpToPixels(Context context, int dp) { Resources res = context.getResources(); return (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, dp, res.getDisplayMetrics()); }
From source file:Main.java
public static int getPixels(Context context, int dipValue) { Resources r = context.getResources(); int px = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, dipValue, r.getDisplayMetrics()); return px;// w w w . j av a 2s . c om }
From source file:Main.java
/** * dp to px//from w w w. j av a2s. c o m * @param dip * @param context * @return */ public static int dipTopx(float dip, Context context) { int num = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, dip, context.getResources().getDisplayMetrics()); return num; }
From source file:Main.java
/** * dpTopx/*from w w w. j a v a 2 s.co m*/ * * @param context * @param val * @return */ public static int dp2px(Context context, float dpVal) { return (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, dpVal, context.getResources().getDisplayMetrics()); }
From source file:Main.java
public static int dip2Px(Resources res, int dip) { DisplayMetrics dm = res.getDisplayMetrics(); return Math.round(TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, dip, dm)); }
From source file:Main.java
public static int dpToPx(Context c, float dipValue) { DisplayMetrics metrics = c.getResources().getDisplayMetrics(); return (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, dipValue, metrics); }
From source file:Main.java
static int dipToPx(Context context, float value) { DisplayMetrics metrics = context.getResources().getDisplayMetrics(); return (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, value, metrics); }
From source file:Main.java
public static float dipToPx(Context context, float value) { DisplayMetrics metrics = context.getResources().getDisplayMetrics(); return TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, value, metrics); }