Android Pixel to Dip Convert px2dip(Context context, float pxValue)

Here you can find the source of px2dip(Context context, float pxValue)

Description

pxdip

Declaration

public static int px2dip(Context context, float pxValue) 

Method Source Code

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

public class Main {

    public static int px2dip(Context context, float pxValue) {
        final float scale = context.getResources().getDisplayMetrics().density;
        return (int) (pxValue / scale + 0.5f);
    }//  w  w w  . j  a  va  2s  . c  o  m
}

Related

  1. convertPixelsToDp(Context context, float pxValue)
  2. convertPixelsToDp(Context ctx, float px)
  3. convertPixelsToSp(Context context, float pxValue)
  4. px2dip(Context context, float pxValue)
  5. px2dip(Context context, float pxValue)
  6. px2dip(Context context, float pxValue)
  7. px2dip(Context context, float pxvalue)
  8. px2dip(float pxValue, float scale)