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; public class Main { public static int sp2px(Context context, float spValue) { final float fontScale = context.getResources().getDisplayMetrics().scaledDensity; return (int) (spValue * fontScale + 0.5f); }/* w ww .jav a 2 s . c o m*/ }