Java tutorial
//package com.java2s; //License from project: Apache License import android.content.Context; public class Main { public static int getScreenSp(Context context) { final float fontScale = context.getResources().getDisplayMetrics().scaledDensity; return (int) (fontScale + 0.5f); } }