Java tutorial
//package com.java2s; //License from project: Apache License import android.content.Context; import android.util.TypedValue; public class Main { /** * px = dp * (dpi / 160) * * @param ctx * @param dip * @return */ public static int dipToPX(final Context ctx, float dip) { return (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, dip, ctx.getResources().getDisplayMetrics()); } }