code: public static int dipToPixel(Resources resources, int dip) {
          final float scale = resources.getDisplayMetrics().density;
          // add 0.5f to round the figure up to the nearest whole number
          return (int) (dip * scale + 0.5f);
      }
docs: Convert the dips to pixels, based on density scale.
  
  @param resources application resources.
  @param dip to be converted value.
  @return converted value(px).