code: public static float pixelsFromSpResource(Context context, @DimenRes int sizeRes) {
          final Resources res = context.getResources();
          return res.getDimension(sizeRes) / res.getDisplayMetrics().density;
      }
docs: Resolves a dimension resource that uses scaled pixels
  
  @param context the current context
  @param sizeRes the dimension resource holding an SP value
  @return the text size in pixels