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

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

Description

pxdip

License

Apache License

Declaration

public static int px2dip(Context context, float pxvalue) 

Method Source Code

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

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  v  a2s  .co m
}

Related

  1. convertPixelsToSp(Context context, float pxValue)
  2. px2dip(Context context, float pxValue)
  3. px2dip(Context context, float pxValue)
  4. px2dip(Context context, float pxValue)
  5. px2dip(Context context, float pxValue)
  6. px2dip(float pxValue, float scale)
  7. px2dp(Context context, int px)
  8. px2sp(Context context, float pxValue)
  9. px2sp(Context context, float pxValue)