List of utility methods to do Dip to Pixel Convert
int | converSpToPixel(Context context, float spValue) conver Sp To Pixel Resources resources = context.getResources(); DisplayMetrics metrics = resources.getDisplayMetrics(); return (int) (spValue * metrics.scaledDensity + 0.5f); |
float | convertDpToPixel(Context context, float dpValue) convert Dp To Pixel Resources resources = context.getResources();
DisplayMetrics metrics = resources.getDisplayMetrics();
return dpValue * (metrics.densityDpi / 160f);
|
float | convertDpToPixel(Context ctx, float dp) This method converts dp unit to equivalent device specific value in pixels. Resources resources = ctx.getResources();
DisplayMetrics metrics = resources.getDisplayMetrics();
return dp * (metrics.densityDpi / 160f);
|
int | dip2pixel(Context context, int dip) http://developer.android.com/guide/practices/screens_support.html#dips-pels final float scale = context.getResources().getDisplayMetrics().density; return (int) (dip * scale + 0.5f); |
int | dip2px(Context context, float dipValue) dippx final float scale = context.getResources().getDisplayMetrics().density; return (int) (dipValue * scale + 0.5f); |
int | getPixels(int dp, Context context) get Pixels final float scale = context.getResources().getDisplayMetrics().density; int px = (int) (dp * scale + 0.5f); return px; |
int | dip2Px(Context context, float dipValue) dip Px final float scale = getDensity(context); return (int) (dipValue * scale + 0.5f); |
int | dip2px(Context context, float dpValue) dippx final float scale = context.getResources().getDisplayMetrics().density; return (int) (dpValue * scale + 0.5f); |
int | dip2px(Context context, float dpValue) dip to px final float scale = context.getResources().getDisplayMetrics().density; return (int) (dpValue * scale + 0.5f); |
int | dip2px(Context context, float dpvalue) dippx final float scale = context.getResources().getDisplayMetrics().density; return (int) (dpvalue * scale + 0.5f); |