Java tutorial
//package com.java2s; import android.content.Context; import android.util.TypedValue; public class Main { /** * spTopx * * @param context * @param val * @return */ public static int sp2px(Context context, float spVal) { return (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_SP, spVal, context.getResources().getDisplayMetrics()); } }