Here you can find the source of convertPixtoDip(int pixel, Context context)
public static int convertPixtoDip(int pixel, Context context)
//package com.java2s; import android.content.Context; public class Main { public static int convertPixtoDip(int pixel, Context context) { float scale = getDensity(context); return (int) ((pixel - 0.5f) / scale); }/*from w ww . j a v a 2s . c om*/ public static float getDensity(Context context) { float scale = context.getResources().getDisplayMetrics().density; return scale; } }