public static int pixelsWidth ( final DisplayMetrics displayMetrics , final int dip ) { final float scale = displayMetrics . density ; final float alpha = 0.5f ; return ( int ) ( dip * scale + alpha ) ; }
Converts device independent points to actual pixels .