Java tutorial
//package com.java2s; import android.content.Context; import android.content.res.Resources; import android.util.TypedValue; public class Main { public static float sp2px(Context context, float sp) { if (context == null) { return sp; } Resources r = context.getResources(); float size = TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_SP, sp, r.getDisplayMetrics()); return size; } }