Here you can find the source of sp2px(Context context, float spValue)
public static int sp2px(Context context, float spValue)
//package com.java2s; import android.content.Context; public class Main { public static int sp2px(Context context, float spValue) { final float scale = getDensity(context); return (int) (spValue * scale + 0.5f); }/*from w w w . jav a 2s . com*/ /** * * @param context * @return */ public static float getDensity(Context context) { return context.getResources().getDisplayMetrics().density; } }