Java tutorial
//package com.java2s; //License from project: Open Source License import android.content.Context; public class Main { public static int sp2px(Context context, float spValue) { return dp2px(context, spValue); } public static int dp2px(Context context, float dpValue) { final float scale = context.getResources().getDisplayMetrics().density; return Math.round(dpValue * scale); } }