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

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

Description

http://developer.android.com/guide/practices/screens_support.html#dips-pels

Declaration

public static int dip2pixel(Context context, int dip) 

Method Source Code

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

public class Main {
    /**//from w  w w.j  a  va2 s  . c  o  m
     * http://developer.android.com/guide/practices/screens_support.html#dips-pels
     */
    public static int dip2pixel(Context context, int dip) {
        final float scale = context.getResources().getDisplayMetrics().density;
        return (int) (dip * scale + 0.5f);
    }
}

Related

  1. converSpToPixel(Context context, float spValue)
  2. convertDpToPixel(Context context, float dpValue)
  3. convertDpToPixel(Context ctx, float dp)
  4. dip2px(Context context, float dipValue)
  5. getPixels(int dp, Context context)
  6. dip2Px(Context context, float dipValue)
  7. dip2px(Context context, float dpValue)