Java tutorial
//package com.java2s; //License from project: Apache License import android.content.Context; public class Main { public static int sp2px(Context context, float spValue) { float scale = context.getResources().getDisplayMetrics().scaledDensity; return (int) (spValue * scale + 0.5f); } }