Android Dip to Pixel Convert convertDIP2PX(Context context, float dip)

Here you can find the source of convertDIP2PX(Context context, float dip)

Description

convert DIPPX

Declaration

public static int convertDIP2PX(Context context, float dip) 

Method Source Code

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

public class Main {
    public static int convertDIP2PX(Context context, float dip) {
        Resources resources = context.getResources();
        float scale = resources.getDisplayMetrics().density;
        resources = null;/*from   w ww .j  ava  2 s  . co  m*/
        return (int) (dip * scale + 0.5f * (dip >= 0 ? 1 : -1));
    }
}

Related

  1. dip2px(Context context, float dipValue)
  2. dip2px(Context context, float dpValue)
  3. dip2px(Context context, float dpValue)
  4. dipToPixel(int dip)
  5. dipsToPixels(Context aContext, int aDip)
  6. sp2px(Context context, float spValue)
  7. scaleDpToPixels(double value, Resources res)
  8. convertDpToPixel(float dp, Context context)
  9. convertDpToPixel(float dp, Resources resources)