Skip to content

Commit c063059

Browse files
dsn5ftymarian
authored andcommitted
Fix MaterialShapeDrawable stroke corner bug
PiperOrigin-RevId: 272977992 (cherry picked from commit ab54c23)
1 parent a0547c6 commit c063059

File tree

2 files changed

+4
-3
lines changed

2 files changed

+4
-3
lines changed

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1103,6 +1103,7 @@ protected final void calculatePathForSize(@NonNull RectF bounds, @NonNull Path p
11031103
private void calculateStrokePath() {
11041104
// Adjust corner radius in order to draw the stroke so that the corners of the background are
11051105
// drawn on top of the edges.
1106+
final float strokeInsetLength = -getStrokeInsetLength();
11061107
strokeShapeAppearance =
11071108
getShapeAppearanceModel()
11081109
.withTransformedCornerSizes(
@@ -1114,7 +1115,7 @@ public CornerSize apply(@NonNull CornerSize cornerSize) {
11141115
// bounds change.
11151116
return cornerSize instanceof RelativeCornerSize
11161117
? cornerSize
1117-
: new AdjustedCornerSize(-getStrokeInsetLength(), cornerSize);
1118+
: new AdjustedCornerSize(strokeInsetLength, cornerSize);
11181119
}
11191120
});
11201121

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -774,9 +774,9 @@ public interface CornerSizeUnaryOperator {
774774
public ShapeAppearanceModel withTransformedCornerSizes(@NonNull CornerSizeUnaryOperator op) {
775775
return toBuilder()
776776
.setTopLeftCornerSize(op.apply(getTopLeftCornerSize()))
777-
.setTopRightCornerSize(op.apply(getTopLeftCornerSize()))
777+
.setTopRightCornerSize(op.apply(getTopRightCornerSize()))
778778
.setBottomLeftCornerSize(op.apply(getBottomLeftCornerSize()))
779-
.setBottomRightCornerSize(op.apply(getBottomLeftCornerSize()))
779+
.setBottomRightCornerSize(op.apply(getBottomRightCornerSize()))
780780
.build();
781781
}
782782

0 commit comments

Comments
 (0)