Android Dip to Pixel Convert convertDiptoPix(int dip, Context context)

Here you can find the source of convertDiptoPix(int dip, Context context)

Description

convert Dipto Pix

Declaration

public static int convertDiptoPix(int dip, Context context) 

Method Source Code

//package com.java2s;
import android.content.Context;

public class Main {
    public static int convertDiptoPix(int dip, Context context) {
        float scale = getDensity(context);
        return (int) (dip * scale + 0.5f);
    }/*from  www  .ja v a2 s  .  c o  m*/

    public static float getDensity(Context context) {
        float scale = context.getResources().getDisplayMetrics().density;
        return scale;
    }
}

Related

  1. convertDpToPixel(float dp, Context context)
  2. convertDpToPixel(float dp, Resources resources)
  3. dipToPixels(int dip)
  4. sp2px(Context context, float spValue)
  5. sp2px(float sp, Context context)