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

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

Description

Convert dip to px value

Declaration

public static int dip2px(Context context, int dip) 

Method Source Code

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

public class Main {
    /**/* w  w  w  .j  a v a  2s  . com*/
     * Convert dip to px value
     * 
     * @author Sean Zheng
     * @CreateDate 2013-4-24
     */
    public static int dip2px(Context context, int dip) {
        final float scale = context.getResources().getDisplayMetrics().density;
        return (int) (dip * scale + 0.5f);
    }
}

Related

  1. sp2px(Context context, float spValue)
  2. spToPx(Context context, int spValue)
  3. convertToPixel(Context context, float dp)
  4. getPixelFromDp(float dp, Context context)
  5. convertDptoPx(Context context, int dp)
  6. dipValue(Context context, int dip)
  7. dip2pixel(Context context, float n)
  8. dip2px(Context context, float dipValue)
  9. dip2px(Context context, float dipValue)