Here you can find the source of dip2pixel(Context context, int dip)
http://developer.android.com/guide/practices/screens_support.html#dips-pels
public static int dip2pixel(Context context, int dip)
//package com.java2s; import android.content.Context; public class Main { /**//from w w w.j a va2 s . c o m * http://developer.android.com/guide/practices/screens_support.html#dips-pels */ public static int dip2pixel(Context context, int dip) { final float scale = context.getResources().getDisplayMetrics().density; return (int) (dip * scale + 0.5f); } }