Java tutorial
//package com.java2s; import android.content.Context; import android.content.res.Resources; public class Main { public static int sp2px(Context context, float spValue) { Resources resources = context.getResources(); final float fontScale = resources.getDisplayMetrics().scaledDensity; resources = null; return (int) (spValue * fontScale + 0.5f); } }