Java tutorial
//package com.java2s; import android.content.Context; import android.content.res.Resources; import android.util.TypedValue; public class Main { /** * Converts a given dip-value into a pixel-value * * @param dip - the dip value to convert * @param context - the application context * @return the converted pixel value */ public static int dipToPx(int dip, Context context) { Resources r = context.getResources(); return (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, dip, r.getDisplayMetrics()); } }