Android Dip to Pixel Convert sp2px(Context context, float spValue)

Here you can find the source of sp2px(Context context, float spValue)

Description

sppx

Declaration

public static int sp2px(Context context, float spValue) 

Method Source Code

//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;
    }
}

Related

  1. dpToPixel(Context context, int dp)
  2. dpToPx(Context context, int dpValue)
  3. dpToPx(Context ctx, int dp)
  4. formatDipToPx(Context context, float dip)
  5. sp2px(Context context, float spValue)
  6. spToPx(Context context, int spValue)
  7. convertToPixel(Context context, float dp)
  8. getPixelFromDp(float dp, Context context)
  9. convertDptoPx(Context context, int dp)