Skip to content

Commit

Permalink
[Button] Fix the issue that button state is not updated
Browse files Browse the repository at this point in the history
On Lollipop, when first assigned as View's background, RippleDrawable won't/can't propagate states to its content drawable. This causes the issue that the state relevant features like stroke colors are not correctly updated when the background is recreated. Explicitly assigns states to the content drawable to fix the issue.

Resolves #1422

PiperOrigin-RevId: 442676637
  • Loading branch information
drchen committed Apr 19, 2022
1 parent db16763 commit 45b99f6
Showing 1 changed file with 5 additions and 0 deletions.
Expand Up @@ -143,6 +143,11 @@ private void updateBackground() {
MaterialShapeDrawable materialShapeDrawable = getMaterialShapeDrawable();
if (materialShapeDrawable != null) {
materialShapeDrawable.setElevation(elevation);
if (IS_LOLLIPOP) {
// Fix the issue that on Lollipop, when first assigned as View's background, RippleDrawable
// won't/can't propagate states to its content drawable. (It somehow works afterwards.)
materialShapeDrawable.setState(materialButton.getDrawableState());
}
}
}

Expand Down

0 comments on commit 45b99f6

Please sign in to comment.