Skip to content

Commit 8e8d20c

Browse files
committed
Fix interpolation for MSD round rects
PiperOrigin-RevId: 296281750
1 parent 08908ca commit 8e8d20c

File tree

2 files changed

+6
-6
lines changed

2 files changed

+6
-6
lines changed

lib/java/com/google/android/material/shape/MaterialShapeDrawable.java

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -467,12 +467,12 @@ protected RectF getBoundsAsRectF() {
467467
return rectF;
468468
}
469469

470-
/** Updates the corners for the given {@link cornerSize}. */
470+
/** Updates the corners for the given {@link CornerSize}. */
471471
public void setCornerSize(float cornerSize) {
472472
setShapeAppearanceModel(drawableState.shapeAppearanceModel.withCornerSize(cornerSize));
473473
}
474474

475-
/** Updates the corners for the given {@link cornerSize}. */
475+
/** Updates the corners for the given {@link CornerSize}. */
476476
public void setCornerSize(@NonNull CornerSize cornerSize) {
477477
setShapeAppearanceModel(drawableState.shapeAppearanceModel.withCornerSize(cornerSize));
478478
}
@@ -1028,7 +1028,9 @@ private void drawShape(
10281028
@NonNull ShapeAppearanceModel shapeAppearanceModel,
10291029
@NonNull RectF bounds) {
10301030
if (shapeAppearanceModel.isRoundRect(bounds)) {
1031-
float cornerSize = shapeAppearanceModel.getTopRightCornerSize().getCornerSize(bounds);
1031+
float cornerSize =
1032+
shapeAppearanceModel.getTopRightCornerSize().getCornerSize(bounds)
1033+
* drawableState.interpolation;
10321034
canvas.drawRoundRect(bounds, cornerSize, cornerSize, paint);
10331035
} else {
10341036
canvas.drawPath(path, paint);
@@ -1171,7 +1173,7 @@ public void getOutline(@NonNull Outline outline) {
11711173
}
11721174

11731175
if (isRoundRect()) {
1174-
float radius = getTopLeftCornerResolvedSize();
1176+
float radius = getTopLeftCornerResolvedSize() * drawableState.interpolation;
11751177
outline.setRoundRect(getBounds(), radius);
11761178
return;
11771179
}

lib/javatests/com/google/android/material/shape/MaterialShapeDrawableTest.java

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,11 +26,9 @@
2626
import org.junit.Test;
2727
import org.junit.runner.RunWith;
2828
import org.robolectric.RobolectricTestRunner;
29-
import org.robolectric.annotation.internal.DoNotInstrument;
3029

3130
/** Tests for {@link MaterialShapeDrawable}. */
3231
@RunWith(RobolectricTestRunner.class)
33-
@DoNotInstrument
3432
public class MaterialShapeDrawableTest {
3533

3634
private static final float ELEVATION = 4;

0 commit comments

Comments
 (0)