Java tutorial
//package com.java2s; //License from project: Open Source License import android.content.Context; public class Main { public static int pix2dip(Context context, int pixs) { int densityDpi = context.getResources().getDisplayMetrics().densityDpi; return (pixs * 160) / densityDpi; } }