Here you can find the source of dipsToPixels(Context aContext, int aDip)
Parameter | Description |
---|---|
aContext | - context required to retrieve device metrics |
aDip | - DIP value to convert to pixels. |
static public int dipsToPixels(Context aContext, int aDip)
//package com.java2s; //License from project: Apache License import android.content.Context; import android.util.TypedValue; public class Main { /**//from w w w . ja va2 s . co m * Converts the given DIPs into current device/resolution pixels. * @param aContext - context required to retrieve device metrics * @param aDip - DIP value to convert to pixels. * @return Rerturns the pixel count for the given DIP. * @author Ryan Fischbach */ static public int dipsToPixels(Context aContext, int aDip) { float px = TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, aDip, aContext.getResources().getDisplayMetrics()); return Math.round(px); } }