Android Dip to Pixel Convert getPixels(int dp, Context context)

Here you can find the source of getPixels(int dp, Context context)

Description

get Pixels

Declaration

public static int getPixels(int dp, Context context) 

Method Source Code

//package com.java2s;

import android.content.Context;

public class Main {
    public static int getPixels(int dp, Context context) {

        final float scale = context.getResources().getDisplayMetrics().density;
        int px = (int) (dp * scale + 0.5f);

        return px;

    }//from  w w w .  j a v a  2 s .co m
}

Related

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