Java tutorial
//package com.java2s; import android.content.Context; import android.util.TypedValue; public class Main { public static int intToDip(Context context, int value) { return (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, value, context.getResources().getDisplayMetrics()); } }