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
/** * px = dp * (dpi / 160)/*from ww w . j a va 2 s . com*/ * * @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 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/*from w ww . jav a 2 s . c om*/ * * 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.//from ww w. ja v a2s. c o m * @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()); }
From source file:Main.java
/** * Convert a dp float value to pixels// ww w . j a va2s . com * * @param dp float value in dps to convert * @return DP value converted to pixels */ static int dp2px(Context context, float dp) { float px = TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, dp, context.getResources().getDisplayMetrics()); return Math.round(px); }
From source file:Main.java
/** * Function to convert the given size in dp. * @param mContext context of the activity. * @param iValue value the needed to be changed. * @return value in dp// w ww .ja va 2 s . c o m */ public static int getSizeInDp(Context mContext, int iValue) { return Math.round(TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, iValue, mContext.getResources().getDisplayMetrics())); }