Android Pixel to Dip Convert getPixelsFromDIP(Context context, int dipValue)

Here you can find the source of getPixelsFromDIP(Context context, int dipValue)

Description

get Pixels From DIP

Declaration

public static float getPixelsFromDIP(Context context, int dipValue) 

Method Source Code

//package com.java2s;

import android.content.Context;

import android.util.TypedValue;

public class Main {
    public static float getPixelsFromDIP(Context context, int dipValue) {
        if (context != null) {
            return TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP,
                    dipValue, context.getResources().getDisplayMetrics());
        }//from   ww w  . ja v  a 2  s.co  m
        return dipValue;
    }
}

Related

  1. pixelsAsDp(Context context, int sizeInPx)
  2. pixelsToDpi(Resources res, int pixels)
  3. convertPX2DIP(Context context, float px)
  4. px2dip(Context context, float px)
  5. px2sp(Context context, float pxValue)
  6. pixel2dip(Context context, float n)
  7. convertPixtoDip(int pixel, Context context)