Java tutorial
//package com.java2s; import android.content.Context; import android.content.res.Resources; public class Main { /** * Converte de DIP para Pixels */ public static float toPixels(Context context, float dip) { Resources r = context.getResources(); //int px = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, dip, r.getDisplayMetrics()); float scale = r.getDisplayMetrics().density; int px = (int) (dip * scale + 0.5f); return px; } }