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