Java tutorial
//package com.java2s; import android.content.Context; import android.util.DisplayMetrics; import android.util.TypedValue; public class Main { public static int dpToPx(Context c, float dipValue) { DisplayMetrics metrics = c.getResources().getDisplayMetrics(); return (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, dipValue, metrics); } }