Java tutorial
//package com.java2s; import android.content.Context; public class Main { public static int px2dip(int pxValue, Context context) { return (int) ((pxValue - 0.5f) / context.getResources().getDisplayMetrics().density); } }