code: public static int convertToDip(DisplayMetrics displayMetrics, int sizeInPixels) {
          return (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, sizeInPixels, displayMetrics);
      }
docs: Converts the number in pixels to the number in dips