Java tutorial
//package com.java2s; import android.util.DisplayMetrics; public class Main { static int dpToPx(float dp, float ppi, DisplayMetrics displayMetrics) { dp /= displayMetrics.density; int px = Math.round(dp * (ppi / DisplayMetrics.DENSITY_DEFAULT)); return px; } }