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