Here you can find the source of px2dip(float pxValue, float scale)
public static int px2dip(float pxValue, float scale)
//package com.java2s; public class Main { public static int px2dip(float pxValue, float scale) { return (int) (pxValue / scale + 0.5f); }//from ww w.j a va2s. co m }