Java tutorial
//package com.java2s; import android.util.TypedValue; import android.view.View; public class Main { public static int getPixelFromDIP(final View view, int value) { return (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, value, view.getResources().getDisplayMetrics()); } }