Java tutorial
//package com.java2s; //License from project: Apache License import android.content.Context; import android.content.res.Resources; import android.util.TypedValue; public class Main { /** * * @param context * @param dip * @return */ public static float dipToPixels(Context context, int dip) { Resources r = context.getResources(); float px = TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, dip, r.getDisplayMetrics()); return px; } }