code: private void obtainGravity(@StyleRes final int themeResourceId) {
          TypedArray typedArray = getContext().getTheme()
                  .obtainStyledAttributes(themeResourceId, new int[]{R.attr.materialDialogGravity});
          setGravity(typedArray.getInteger(0, Dialog.Gravity.CENTER));
      }
docs: Obtains the gravity from a specific theme.
  
  @param themeResourceId
  The resource id of the theme, the gravity should be obtained from, as an {@link
  Integer} value