code: private void obtainHeight(@StyleRes final int themeResourceId) {
          TypedArray typedArray = getContext().getTheme()
                  .obtainStyledAttributes(themeResourceId, new int[]{R.attr.materialDialogHeight});
          int defaultValue = Dialog.WRAP_CONTENT;
  
          try {
              setHeight(typedArray.getDimensionPixelSize(0, defaultValue));
          } catch (Resources.NotFoundException | UnsupportedOperationException e) {
              setHeight(typedArray.getInteger(0, defaultValue));
          }
      }
docs: Obtains the height from a specific theme.
  
  @param themeResourceId
  The resource id of the theme, the height should be obtained from, as an {@link
  Integer} value