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