Android Dip to Pixel Convert convertDpToPixel(float dp, Resources resources)

Here you can find the source of convertDpToPixel(float dp, Resources resources)

Description

convert Dp To Pixel

Declaration

public static int convertDpToPixel(float dp, Resources resources) 

Method Source Code

//package com.java2s;

import android.content.res.Resources;

import android.util.DisplayMetrics;

public class Main {
    public static int convertDpToPixel(float dp, Resources resources) {
        DisplayMetrics metrics = resources.getDisplayMetrics();
        float px = dp * (metrics.densityDpi / 160f);
        return (int) px;
    }//  www .  j  av a 2  s. c  o  m
}

Related

  1. dipsToPixels(Context aContext, int aDip)
  2. convertDIP2PX(Context context, float dip)
  3. sp2px(Context context, float spValue)
  4. scaleDpToPixels(double value, Resources res)
  5. convertDpToPixel(float dp, Context context)
  6. dipToPixels(int dip)
  7. sp2px(Context context, float spValue)
  8. sp2px(float sp, Context context)
  9. convertDiptoPix(int dip, Context context)