Skip to content

Commit 491cb44

Browse files
skv-headlessbubblesunyum
authored andcommitted
fix border style without borderRadius
Summary: closes facebook#6721 closes facebook#3159 before(without borderRadius) ![bug](https://cloud.githubusercontent.com/assets/1488195/14235087/fcf79f8a-f9eb-11e5-9d44-7ab1d131be24.jpg) after ![fix](https://cloud.githubusercontent.com/assets/1488195/14235067/8cf128b4-f9eb-11e5-8170-ad3a146d6104.jpg) Closes facebook#6789 Differential Revision: D3240657 Pulled By: mkonicek fb-gh-sync-id: 4eb8f72d7278d880297fb73653ef530719af3d5b fbshipit-source-id: 4eb8f72d7278d880297fb73653ef530719af3d5b
1 parent 354619d commit 491cb44

File tree

2 files changed

+14
-5
lines changed

2 files changed

+14
-5
lines changed

Examples/UIExplorer/ViewExample.js

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

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

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -95,10 +95,14 @@ private static enum BorderStyle {
9595

9696
@Override
9797
public void draw(Canvas canvas) {
98-
if ((!CSSConstants.isUndefined(mBorderRadius) && mBorderRadius > 0) || mBorderCornerRadii != null) {
99-
drawRoundedBackgroundWithBorders(canvas);
100-
} else {
98+
updatePathEffect();
99+
boolean roundedBorders = mBorderCornerRadii != null ||
100+
(!CSSConstants.isUndefined(mBorderRadius) && mBorderRadius > 0);
101+
102+
if ((mBorderStyle == null || mBorderStyle == BorderStyle.SOLID) && !roundedBorders) {
101103
drawRectangularBackgroundWithBorders(canvas);
104+
} else {
105+
drawRoundedBackgroundWithBorders(canvas);
102106
}
103107
}
104108

@@ -231,7 +235,6 @@ private void drawRoundedBackgroundWithBorders(Canvas canvas) {
231235
mPaint.setColor(ColorUtil.multiplyColorAlpha(borderColor, mAlpha));
232236
mPaint.setStyle(Paint.Style.STROKE);
233237
mPaint.setStrokeWidth(fullBorderWidth);
234-
mPaint.setPathEffect(mPathEffectForBorderStyle);
235238
canvas.drawPath(mPathForBorderRadius, mPaint);
236239
}
237240
}
@@ -298,10 +301,17 @@ private void updatePath() {
298301
bottomLeftRadius + extraRadiusForOutline
299302
},
300303
Path.Direction.CW);
304+
}
301305

306+
/**
307+
* Set type of border
308+
*/
309+
private void updatePathEffect() {
302310
mPathEffectForBorderStyle = mBorderStyle != null
303311
? mBorderStyle.getPathEffect(getFullBorderWidth())
304312
: null;
313+
314+
mPaint.setPathEffect(mPathEffectForBorderStyle);
305315
}
306316

307317
/**

0 commit comments

Comments
 (0)