Java tutorial
//package com.java2s; import android.content.*; public class Main { public static int dip2px(Context context, float f) { return (int) (0.5F + f * context.getResources().getDisplayMetrics().density); } }