Android Dip to Pixel Convert formatDipToPx(Context context, float dip)

Here you can find the source of formatDipToPx(Context context, float dip)

Description

format Dip To Px

Declaration

public static int formatDipToPx(Context context, float dip) 

Method Source Code

//package com.java2s;
import android.app.Activity;
import android.content.Context;
import android.util.DisplayMetrics;

public class Main {
    public static int formatDipToPx(Context context, float dip) {
        DisplayMetrics dm = new DisplayMetrics();
        ((Activity) context).getWindowManager().getDefaultDisplay()
                .getMetrics(dm);//from   www.  j a v  a 2 s  . co  m
        return (int) Math.ceil(dip * dm.density);
    }
}

Related

  1. dipToPixels(Context context, float dipValue)
  2. dp2px(Context context, float dp)
  3. dpToPixel(Context context, int dp)
  4. dpToPx(Context context, int dpValue)
  5. dpToPx(Context ctx, int dp)
  6. sp2px(Context context, float spValue)
  7. sp2px(Context context, float spValue)
  8. spToPx(Context context, int spValue)
  9. convertToPixel(Context context, float dp)