Java tutorial
//package com.java2s; import android.content.res.Resources; import android.util.TypedValue; public class Main { public static float dpToPx(Resources res, float dp) { float px = TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, dp, res.getDisplayMetrics()); return px; } }