Java tutorial
//package com.java2s; import android.util.DisplayMetrics; import android.util.TypedValue; public class Main { static public int getPixelFromDip(DisplayMetrics dm, float dip) { return (int) (TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, dip, dm) + 0.5f); } }