Java tutorial
//package com.java2s; //License from project: Apache License import android.content.Context; import android.util.Log; public class Main { private static final String TAG = "BringLuckUtil"; public static int getPxToDp(Context con, int px) { float density = 0.0f; density = con.getResources().getDisplayMetrics().density; Log.d(TAG, "density = " + density); return (int) (px / density); } }