Java tutorial
//package com.java2s; import android.content.res.Resources; public class Main { public static int transDip(int dip) { float scale = Resources.getSystem().getDisplayMetrics().density; return (int) (dip * scale + 0.5f); } }