Java tutorial
//package com.java2s; import android.content.res.Resources; import android.util.DisplayMetrics; import android.util.TypedValue; public class Main { public static int dpToPixels(int dp) { DisplayMetrics displayMetrics = Resources.getSystem().getDisplayMetrics(); return Math.round(TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, dp, displayMetrics)); //return Math.round(dp * Resources.getSystem().getDisplayMetrics().density); } }