@@ -89,6 +89,7 @@ private enum BorderStyle {
89
89
private @ Nullable Path mOuterClipPathForBorderRadius ;
90
90
private @ Nullable Path mPathForBorderRadiusOutline ;
91
91
private @ Nullable Path mPathForBorder ;
92
+ private Path mPathForSingleBorder = new Path ();
92
93
private @ Nullable Path mCenterDrawPath ;
93
94
private @ Nullable RectF mInnerClipTempRectForBorderRadius ;
94
95
private @ Nullable RectF mOuterClipTempRectForBorderRadius ;
@@ -968,6 +969,14 @@ private void updatePathEffect() {
968
969
mPaint .setPathEffect (mPathEffectForBorderStyle );
969
970
}
970
971
972
+ private void updatePathEffect (int borderWidth ) {
973
+ PathEffect pathEffectForBorderStyle = null ;
974
+ if (mBorderStyle != null ) {
975
+ pathEffectForBorderStyle = BorderStyle .getPathEffect (mBorderStyle , borderWidth );
976
+ }
977
+ mPaint .setPathEffect (pathEffectForBorderStyle );
978
+ }
979
+
971
980
/** For rounded borders we use default "borderWidth" property. */
972
981
public float getFullBorderWidth () {
973
982
return (mBorderWidth != null && !YogaConstants .isUndefined (mBorderWidth .getRaw (Spacing .ALL )))
@@ -1083,28 +1092,50 @@ private void drawRectangularBackgroundWithBorders(Canvas canvas) {
1083
1092
colorTop ,
1084
1093
colorRight ,
1085
1094
colorBottom );
1095
+
1086
1096
if (fastBorderColor != 0 ) {
1087
1097
if (Color .alpha (fastBorderColor ) != 0 ) {
1088
1098
// Border color is not transparent.
1089
1099
int right = bounds .right ;
1090
1100
int bottom = bounds .bottom ;
1091
1101
1092
1102
mPaint .setColor (fastBorderColor );
1103
+ mPaint .setStyle (Paint .Style .STROKE );
1093
1104
if (borderLeft > 0 ) {
1094
- int leftInset = left + borderLeft ;
1095
- canvas .drawRect (left , top , leftInset , bottom - borderBottom , mPaint );
1105
+ mPathForSingleBorder .reset ();
1106
+ int width = Math .round (borderWidth .left );
1107
+ updatePathEffect (width );
1108
+ mPaint .setStrokeWidth (width );
1109
+ mPathForSingleBorder .moveTo (left , top - borderWidth .top / 2 );
1110
+ mPathForSingleBorder .lineTo (left , bottom + borderWidth .bottom / 2 );
1111
+ canvas .drawPath (mPathForSingleBorder , mPaint );
1096
1112
}
1097
1113
if (borderTop > 0 ) {
1098
- int topInset = top + borderTop ;
1099
- canvas .drawRect (left + borderLeft , top , right , topInset , mPaint );
1114
+ mPathForSingleBorder .reset ();
1115
+ int width = Math .round (borderWidth .top );
1116
+ updatePathEffect (width );
1117
+ mPaint .setStrokeWidth (width );
1118
+ mPathForSingleBorder .moveTo (left , top );
1119
+ mPathForSingleBorder .lineTo (right , top );
1120
+ canvas .drawPath (mPathForSingleBorder , mPaint );
1100
1121
}
1101
1122
if (borderRight > 0 ) {
1102
- int rightInset = right - borderRight ;
1103
- canvas .drawRect (rightInset , top + borderTop , right , bottom , mPaint );
1123
+ mPathForSingleBorder .reset ();
1124
+ int width = Math .round (borderWidth .right );
1125
+ updatePathEffect (width );
1126
+ mPaint .setStrokeWidth (width );
1127
+ mPathForSingleBorder .moveTo (right , top - borderWidth .top / 2 );
1128
+ mPathForSingleBorder .lineTo (right , bottom + borderWidth .bottom / 2 );
1129
+ canvas .drawPath (mPathForSingleBorder , mPaint );
1104
1130
}
1105
1131
if (borderBottom > 0 ) {
1106
- int bottomInset = bottom - borderBottom ;
1107
- canvas .drawRect (left , bottomInset , right - borderRight , bottom , mPaint );
1132
+ mPathForSingleBorder .reset ();
1133
+ int width = Math .round (borderWidth .bottom );
1134
+ updatePathEffect (width );
1135
+ mPaint .setStrokeWidth (width );
1136
+ mPathForSingleBorder .moveTo (left , bottom );
1137
+ mPathForSingleBorder .lineTo (right , bottom );
1138
+ canvas .drawPath (mPathForSingleBorder , mPaint );
1108
1139
}
1109
1140
}
1110
1141
} else {
0 commit comments