Java tutorial
//package com.java2s; //License from project: LGPL import android.content.Context; import android.util.TypedValue; public class Main { public static int getPX(Context context, int dipValue) { float px = TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, dipValue, context.getResources().getDisplayMetrics()); return (int) px; } }