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

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

Description

convert Dpto Px

Declaration

public static int convertDptoPx(Context context, int dp) 

Method Source Code

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

public class Main {
    public static int convertDptoPx(Context context, int dp) {
        float scale = context.getResources().getDisplayMetrics().density;
        return (int) (dp * scale + 0.5f);

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

Related

  1. sp2px(Context context, float spValue)
  2. sp2px(Context context, float spValue)
  3. spToPx(Context context, int spValue)
  4. convertToPixel(Context context, float dp)
  5. getPixelFromDp(float dp, Context context)
  6. dip2px(Context context, int dip)
  7. dipValue(Context context, int dip)
  8. dip2pixel(Context context, float n)
  9. dip2px(Context context, float dipValue)