code: @SuppressLint("Recycle")
      public static TypedArray getDialogStyledAttributes(Context activity, int[] attrs, int defStyleAttr, int defStyleRef) {
          AlertDialog.Builder builder = new AlertDialog.Builder(activity);
          AlertDialog dialog = builder.create();
          TypedArray ta = dialog.getContext().obtainStyledAttributes(null, attrs, defStyleAttr, defStyleRef);
          dialog.dismiss();
          return ta;
      }
docs: Read styled attributes, they will defined in an AlertDialog shown by the given activity.
  You must call {@link TypedArray#recycle()} after having read the desired attributes.
  @see Context#obtainStyledAttributes(android.util.AttributeSet, int[], int, int)