Java tutorial
//package com.java2s; //License from project: Open Source License import android.content.Context; import android.util.TypedValue; public class Main { /** * Convert dip to pixels * * param size The size to be converted * * @author Melvin Lobo */ public static float d2x(Context context, int size) { return TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, size, context.getResources().getDisplayMetrics()); } }