code: private void adaptBackground(@Nullable final BackgroundAnimation animation) {
          if (getRootView() != null && getWindow() != null) {
              Drawable newBackground = background;
  
              if (animation != null && newBackground != null) {
                  View animatedView = isFullscreen() ? getWindow().getDecorView() : getRootView();
                  Drawable previousBackground = animatedView.getBackground();
  
                  if (previousBackground != null) {
                      if (previousBackground instanceof AbstractTransitionDrawable) {
                          previousBackground =
                                  ((AbstractTransitionDrawable) previousBackground).getDrawable(1);
                      }
  
                      if (animation instanceof CircleTransitionAnimation) {
                          CircleTransitionAnimation circleTransitionAnimation =
                                  (CircleTransitionAnimation) animation;
                          CircleTransitionDrawable transition = new CircleTransitionDrawable(
                                  new Drawable[]{previousBackground, newBackground});
                          transition.setRadius(circleTransitionAnimation.getRadius());
                          transition.setListener(circleTransitionAnimation.getListener());
  
                          if (circleTransitionAnimation.getX() != null) {
                              transition.setX(circleTransitionAnimation.getX());
                          }
  
                          if (circleTransitionAnimation.getY() != null) {
                              transition.setY(circleTransitionAnimation.getY());
                          }
  
                          transition.startTransition(circleTransitionAnimation.getDuration());
                          newBackground = transition;
                      } else if (animation instanceof CrossFadeTransitionAnimation) {
                          CrossFadeTransitionDrawable transition = new CrossFadeTransitionDrawable(
                                  new Drawable[]{previousBackground, newBackground});
                          transition.setListener(animation.getListener());
                          transition.startTransition(animation.getDuration());
                          newBackground = transition;
                      } else {
                          throw new RuntimeException("Unknown type of animation: " +
                                  animation.getClass().getSimpleName());
                      }
                  }
              }
  
              getWindow().setBackgroundDrawable(new ColorDrawable(Color.TRANSPARENT));
              ViewUtil.setBackground(getRootView(), isFullscreen() ? null : newBackground);
              ViewUtil.setBackground(getWindow().getDecorView(),
                      isFullscreen() ? newBackground : null);
          }
      }
docs: Adapts the dialog's background.
  
  @param animation
  The animation, which should be used to change the background, as an instance of the
  class {@link BackgroundAnimation} or null, if no animation should be used