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