code: public static void duplicateState(@NonNull final View from, @NonNull final View to) {
          from.getViewTreeObserver().addOnPreDrawListener(new ViewTreeObserver.OnPreDrawListener() {
              @Override
              public boolean onPreDraw() {
                  final int[] state = from.getDrawableState();
  
                  Drawable back = to.getBackground();
                  if (back != null && !Arrays.equals(state, back.getState())) {
                      back.setState(state);
                      back.invalidateSelf();
                  }
  
                  Drawable img = to instanceof ImageView ? ((ImageView) to).getDrawable() : null;
                  if (img != null && !Arrays.equals(state, img.getState())) {
                      img.setState(state);
                      img.invalidateSelf();
                  }
  
                  return true;
              }
          });
      }
docs: Duplicates drawable state from one view to another.<br/>
  E.g. when 'from' view get pressed 'to' view will be switched to pressed state as well.<br/>
  State will be duplicated for both background drawable and to ImageView's drawable
  (if 'to' view is an instance of ImageView).