Skip to content

Commit b0521f8

Browse files
committed
fix border style without borderRadius
call drawRoundedBackgroundWithBorders if borderStyle set
1 parent bef175a commit b0521f8

File tree

2 files changed

+9
-2
lines changed

2 files changed

+9
-2
lines changed

Examples/UIExplorer/ViewExample.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,6 @@ var ViewBorderStyleExample = React.createClass({
4545
<View>
4646
<View style={{
4747
borderWidth: 1,
48-
borderRadius: 5,
4948
borderStyle: this.state.showBorder ? 'dashed' : null,
5049
padding: 5
5150
}}>

ReactAndroid/src/main/java/com/facebook/react/views/view/ReactViewBackgroundDrawable.java

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,8 @@ private static enum BorderStyle {
9595

9696
@Override
9797
public void draw(Canvas canvas) {
98-
if ((!CSSConstants.isUndefined(mBorderRadius) && mBorderRadius > 0) || mBorderCornerRadii != null) {
98+
if ((!CSSConstants.isUndefined(mBorderRadius) && mBorderRadius > 0) || mBorderCornerRadii != null ||
99+
!(mBorderStyle == null || mBorderStyle == BorderStyle.SOLID)) {
99100
drawRoundedBackgroundWithBorders(canvas);
100101
} else {
101102
drawRectangularBackgroundWithBorders(canvas);
@@ -299,6 +300,10 @@ private void updatePath() {
299300
},
300301
Path.Direction.CW);
301302

303+
updatePathEffectForBorderStyle();
304+
}
305+
306+
private void updatePathEffectForBorderStyle() {
302307
mPathEffectForBorderStyle = mBorderStyle != null
303308
? mBorderStyle.getPathEffect(getFullBorderWidth())
304309
: null;
@@ -322,6 +327,7 @@ private int getFullBorderColor() {
322327
}
323328

324329
private void drawRectangularBackgroundWithBorders(Canvas canvas) {
330+
updatePathEffectForBorderStyle();
325331
int useColor = ColorUtil.multiplyColorAlpha(mColor, mAlpha);
326332
if ((useColor >>> 24) != 0) { // color is not transparent
327333
mPaint.setColor(useColor);
@@ -332,6 +338,8 @@ private void drawRectangularBackgroundWithBorders(Canvas canvas) {
332338
if (getBorderWidth(Spacing.LEFT) > 0 || getBorderWidth(Spacing.TOP) > 0 ||
333339
getBorderWidth(Spacing.RIGHT) > 0 || getBorderWidth(Spacing.BOTTOM) > 0) {
334340

341+
mPaint.setPathEffect(mPathEffectForBorderStyle);
342+
335343
int borderLeft = getBorderWidth(Spacing.LEFT);
336344
int borderTop = getBorderWidth(Spacing.TOP);
337345
int borderRight = getBorderWidth(Spacing.RIGHT);

0 commit comments

Comments
 (0)