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 de9dcbc7f..9b995cd5f 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 @@ -359,6 +359,7 @@ import com.facebook.csslayout.Spacing; // maybe draw borders? if (getBorderWidth(Spacing.LEFT) > 0 || getBorderWidth(Spacing.TOP) > 0 || getBorderWidth(Spacing.RIGHT) > 0 || getBorderWidth(Spacing.BOTTOM) > 0) { + Rect bounds = getBounds(); int borderLeft = getBorderWidth(Spacing.LEFT); int borderTop = getBorderWidth(Spacing.TOP); @@ -369,8 +370,10 @@ import com.facebook.csslayout.Spacing; int colorRight = getBorderColor(Spacing.RIGHT); int colorBottom = getBorderColor(Spacing.BOTTOM); - int width = getBounds().width(); - int height = getBounds().height(); + int top = bounds.top; + int left = bounds.left; + int width = bounds.width(); + int height = bounds.height(); // If the path drawn previously is of the same color, // there would be a slight white space between borders @@ -387,44 +390,44 @@ import com.facebook.csslayout.Spacing; if (borderLeft > 0 && colorLeft != Color.TRANSPARENT) { mPaint.setColor(colorLeft); mPathForBorder.reset(); - mPathForBorder.moveTo(0, 0); - mPathForBorder.lineTo(borderLeft, borderTop); - mPathForBorder.lineTo(borderLeft, height - borderBottom); - mPathForBorder.lineTo(0, height); - mPathForBorder.lineTo(0, 0); + mPathForBorder.moveTo(left, top); + mPathForBorder.lineTo(left + borderLeft, top + borderTop); + mPathForBorder.lineTo(left + borderLeft, top + height - borderBottom); + mPathForBorder.lineTo(left, top + height); + mPathForBorder.lineTo(left, top); canvas.drawPath(mPathForBorder, mPaint); } if (borderTop > 0 && colorTop != Color.TRANSPARENT) { mPaint.setColor(colorTop); mPathForBorder.reset(); - mPathForBorder.moveTo(0, 0); - mPathForBorder.lineTo(borderLeft, borderTop); - mPathForBorder.lineTo(width - borderRight, borderTop); - mPathForBorder.lineTo(width, 0); - mPathForBorder.lineTo(0, 0); + mPathForBorder.moveTo(left, top); + mPathForBorder.lineTo(left + borderLeft, top + borderTop); + mPathForBorder.lineTo(left + width - borderRight, top + borderTop); + mPathForBorder.lineTo(left + width, top); + mPathForBorder.lineTo(left, top); canvas.drawPath(mPathForBorder, mPaint); } if (borderRight > 0 && colorRight != Color.TRANSPARENT) { mPaint.setColor(colorRight); mPathForBorder.reset(); - mPathForBorder.moveTo(width, 0); - mPathForBorder.lineTo(width, height); - mPathForBorder.lineTo(width - borderRight, height - borderBottom); - mPathForBorder.lineTo(width - borderRight, borderTop); - mPathForBorder.lineTo(width, 0); + mPathForBorder.moveTo(left + width, top); + mPathForBorder.lineTo(left + width, top + height); + mPathForBorder.lineTo(left + width - borderRight, top + height - borderBottom); + mPathForBorder.lineTo(left + width - borderRight, top + borderTop); + mPathForBorder.lineTo(left + width, top); canvas.drawPath(mPathForBorder, mPaint); } if (borderBottom > 0 && colorBottom != Color.TRANSPARENT) { mPaint.setColor(colorBottom); mPathForBorder.reset(); - mPathForBorder.moveTo(0, height); - mPathForBorder.lineTo(width, height); - mPathForBorder.lineTo(width - borderRight, height - borderBottom); - mPathForBorder.lineTo(borderLeft, height - borderBottom); - mPathForBorder.lineTo(0, height); + mPathForBorder.moveTo(left, top + height); + mPathForBorder.lineTo(left + width, top + height); + mPathForBorder.lineTo(left + width - borderRight, top + height - borderBottom); + mPathForBorder.lineTo(left + borderLeft, top + height - borderBottom); + mPathForBorder.lineTo(left, top + height); canvas.drawPath(mPathForBorder, mPaint); }