public static float pxToSp ( Context context , Float px ) { float scaledDensity = context . getResources ( ) . getDisplayMetrics ( ) . scaledDensity ; return px / scaledDensity ; }
Convertes pixels to sp