From 7757ad05762284c059807d7d75fd03559e86f2b2 Mon Sep 17 00:00:00 2001 From: Hein Rutjes Date: Sun, 19 Apr 2020 22:48:48 -0700 Subject: [PATCH] Fix border-stroke drawing after resetting border-radius (#28356) Summary: This PR fixes incorrect drawing of the View borders on Android, after changing the border-radius back to 0 *(and when no background-color is defined)*. This happens because the `drawRoundedBackgroundWithBorders` function in ReactViewBackgroundDrawable changes the style on the Paint object to `STROKE`. This style is however never reverted back to `FILL`. This change ensures that the Paint style is set to `FILL` for the full execution of the `drawRectangularBackgroundWithBorders` function. ## Changelog `[Android] [Fixed] - Fix border-drawing when changing border-radius back to 0` Pull Request resolved: https://github.com/facebook/react-native/pull/28356 Test Plan: **Faulty situation:** ![ezgif com-video-to-gif](https://user-images.githubusercontent.com/6184593/77153163-9759b280-6a99-11ea-82bb-33a1e0a4934c.gif) **After the fix:** ![ezgif com-video-to-gif (1)](https://user-images.githubusercontent.com/6184593/77153825-c91f4900-6a9a-11ea-8e0c-a4280b9e72b8.gif) Differential Revision: D21124741 Pulled By: shergin fbshipit-source-id: 2044f8e8ad59a58df42b64d7ee8c4ad1d3b562f1 --- .../facebook/react/views/view/ReactViewBackgroundDrawable.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/ReactAndroid/src/main/java/com/facebook/react/views/view/ReactViewBackgroundDrawable.java b/ReactAndroid/src/main/java/com/facebook/react/views/view/ReactViewBackgroundDrawable.java index 9a8f45c9f10..9fe66d2fad4 100644 --- a/ReactAndroid/src/main/java/com/facebook/react/views/view/ReactViewBackgroundDrawable.java +++ b/ReactAndroid/src/main/java/com/facebook/react/views/view/ReactViewBackgroundDrawable.java @@ -998,10 +998,11 @@ public class ReactViewBackgroundDrawable extends Drawable { } private void drawRectangularBackgroundWithBorders(Canvas canvas) { + mPaint.setStyle(Paint.Style.FILL); + int useColor = ColorUtil.multiplyColorAlpha(mColor, mAlpha); if (Color.alpha(useColor) != 0) { // color is not transparent mPaint.setColor(useColor); - mPaint.setStyle(Paint.Style.FILL); canvas.drawRect(getBounds(), mPaint); }