Android Dip to Pixel Convert dipToPixel(int dip)

Here you can find the source of dipToPixel(int dip)

Description

Converts DIP to pixels.

License

Apache License

Parameter

Parameter Description
dip the value of the dip.

Return

the value of the pixels.

Declaration

public static int dipToPixel(int dip) 

Method Source Code

//package com.java2s;
//License from project: Apache License 

import android.content.res.Resources;

public class Main {
    final static float scale = Resources.getSystem().getDisplayMetrics().density;

    /**/*ww w  .  ja v a 2s.  com*/
     * Converts DIP to pixels.
     * 
     * @param dip
     *            the value of the dip.
     * @return the value of the pixels.
     */
    public static int dipToPixel(int dip) {
        return (int) (dip * scale + 0.5f);
    }
}

Related

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