Here you can find the source of dip2px(Context context, float dipValue)
public static int dip2px(Context context, float dipValue)
//package com.java2s; import android.content.Context; public class Main { public static int dip2px(Context context, float dipValue) { final float scale = context.getResources().getDisplayMetrics().density; return (int) (dipValue * scale + 0.5f); }//from w w w . j a v a 2s .c o m }