Here you can find the source of sp2px(Context context, float spValue)
public static int sp2px(Context context, float spValue)
//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;/* w ww . j a v a 2s . c o m*/ return (int) (spValue * fontScale + 0.5f); } }