public static float pixelToSip ( Context context , float pixels ) { DisplayMetrics metrics = new DisplayMetrics ( ) ; float scaledDensity = metrics . scaledDensity ; if ( pixels == 0 || scaledDensity == 0 ) { return 1 ; } return pixels / scaledDensity ; }
Convert the pixels to sips based on density scale .