Java tutorial
//package com.java2s; //License from project: Open Source License import android.content.Context; import android.util.TypedValue; public class Main { /** * Converts scale pixels to pixels -- used for setting text sizes * * @param context context for getResources() * @param sp desired scale pixels pixels * @return converted sp to pixels */ static int spToPx(Context context, final float sp) { return (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_SP, sp, context.getResources().getDisplayMetrics()); } }