public static int convertDPItoPixels ( Context context , int dpi ) { final float scale = context . getResources ( ) . getDisplayMetrics ( ) . density ; return ( int ) ( dpi * scale + 0.5f ) ; }
Convert a size in dp to a size in pixels