Java tutorial
//package com.java2s; import android.content.Context; public class Main { public static int sp2dx(Context c, float sp) { return (int) (sp * c.getResources().getDisplayMetrics().density); } }