code: static float dpToPixel(float dp, Resources resources) {
          DisplayMetrics metrics = resources.getDisplayMetrics();
          return metrics.density * dp;
      }
docs: Converts from device independent pixels (dp or dip) to
  device dependent pixels. This method returns the input
  multiplied by the display's density. The result is not
  rounded nor clamped.
  
  The value returned by this method is well suited for
  drawing with the Canvas API but should not be used to
  set layout dimensions.
  
  @param dp The value in dp to convert to pixels
  @param resources An instances of Resources