Java tutorial
//package com.java2s; import android.content.res.Resources; public class Main { public static int px2sp(float pxValue) { final float fontScale = Resources.getSystem().getDisplayMetrics().scaledDensity; return (int) (pxValue / fontScale + 0.5f); } }