Java tutorial
//package com.java2s; //License from project: Open Source License import android.content.Context; import android.util.DisplayMetrics; public class Main { public static float px2sp(Context context, float size) { return size / context.getResources().getDisplayMetrics().scaledDensity; } public static DisplayMetrics getDisplayMetrics(Context context) { return context.getResources().getDisplayMetrics(); } }