@@ -98,6 +98,7 @@ public interface OnCheckedChangeListener {
9898 private static final int [] CHECKABLE_STATE_SET = {android .R .attr .state_checkable };
9999 private static final int [] CHECKED_STATE_SET = {android .R .attr .state_checked };
100100 private static final int [] DRAGGED_STATE_SET = {R .attr .state_dragged };
101+ private static final int [] HOVERED_STATE_SET = {android .R .attr .state_hovered };
101102
102103 private static final int DEF_STYLE_RES = R .style .Widget_MaterialComponents_CardView ;
103104 private static final String LOG_TAG = "MaterialCardView" ;
@@ -492,7 +493,7 @@ public void toggle() {
492493
493494 @ Override
494495 protected int [] onCreateDrawableState (int extraSpace ) {
495- final int [] drawableState = super .onCreateDrawableState (extraSpace + 3 );
496+ final int [] drawableState = super .onCreateDrawableState (extraSpace + 8 );
496497 if (isCheckable ()) {
497498 mergeDrawableStates (drawableState , CHECKABLE_STATE_SET );
498499 }
@@ -505,6 +506,28 @@ protected int[] onCreateDrawableState(int extraSpace) {
505506 mergeDrawableStates (drawableState , DRAGGED_STATE_SET );
506507 }
507508
509+ if (isDuplicateParentStateEnabled ()) {
510+ if (isPressed ()) {
511+ mergeDrawableStates (drawableState , PRESSED_STATE_SET );
512+ }
513+
514+ if (isHovered ()) {
515+ mergeDrawableStates (drawableState , HOVERED_STATE_SET );
516+ }
517+
518+ if (isEnabled ()) {
519+ mergeDrawableStates (drawableState , ENABLED_STATE_SET );
520+ }
521+
522+ if (isFocused ()) {
523+ mergeDrawableStates (drawableState , FOCUSED_STATE_SET );
524+ }
525+
526+ if (isSelected ()) {
527+ mergeDrawableStates (drawableState , SELECTED_STATE_SET );
528+ }
529+ }
530+
508531 return drawableState ;
509532 }
510533
0 commit comments