Repository: incubator-weex Updated Branches: refs/heads/master 9e6b5f5ff -> 62439cae0
[android] Fix the display problem of the box-shadow property of the scroller component Project: http://git-wip-us.apache.org/repos/asf/incubator-weex/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-weex/commit/73062333 Tree: http://git-wip-us.apache.org/repos/asf/incubator-weex/tree/73062333 Diff: http://git-wip-us.apache.org/repos/asf/incubator-weex/diff/73062333 Branch: refs/heads/master Commit: 73062333b8c05a34c707c572279da0655ba55c13 Parents: 42aa126 Author: åå¡ <[email protected]> Authored: Mon Mar 12 14:33:35 2018 +0800 Committer: åå¡ <[email protected]> Committed: Mon Mar 12 14:33:35 2018 +0800 ---------------------------------------------------------------------- .../java/com/taobao/weex/utils/BoxShadowUtil.java | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-weex/blob/73062333/android/sdk/src/main/java/com/taobao/weex/utils/BoxShadowUtil.java ---------------------------------------------------------------------- diff --git a/android/sdk/src/main/java/com/taobao/weex/utils/BoxShadowUtil.java b/android/sdk/src/main/java/com/taobao/weex/utils/BoxShadowUtil.java index 288be62..2796b32 100644 --- a/android/sdk/src/main/java/com/taobao/weex/utils/BoxShadowUtil.java +++ b/android/sdk/src/main/java/com/taobao/weex/utils/BoxShadowUtil.java @@ -392,19 +392,23 @@ public class BoxShadowUtil { setBounds(-paddingX, -paddingY, viewRect.width() + paddingX, viewRect.height() + paddingY); } - @Override public void draw(Canvas canvas) { - Rect newRect = canvas.getClipBounds(); + Rect bounds = canvas.getClipBounds(); + Rect newRect = new Rect(bounds); // Make the Canvas Rect bigger according to the padding. newRect.inset(-paddingX * 2, -paddingY * 2); canvas.clipRect(newRect, Region.Op.REPLACE); Path contentPath = new Path(); - RectF rectF = new RectF(0f, 0f, viewRect.width(), viewRect.height()); + // the content area map must be aligned with bounds + RectF rectF = new RectF(bounds); contentPath.addRoundRect(rectF, radii, Path.Direction.CCW); // can not antialias canvas.clipPath(contentPath, Region.Op.DIFFERENCE); + // translate the canvas to a suitable position and then draw the bitmap, otherwise draw from the origin(0, 0) + canvas.translate(bounds.left, bounds.top); + super.draw(canvas); } } @@ -517,12 +521,16 @@ public class BoxShadowUtil { @Override public void draw(Canvas canvas) { + Rect bounds = canvas.getClipBounds(); Path border = new Path(); - RectF rectF = new RectF(0, 0, canvas.getWidth(), canvas.getHeight()); + RectF rectF = new RectF(bounds); border.addRoundRect(rectF, radii, Path.Direction.CCW); canvas.clipPath(border); //TODO: we need clip border-width too + // translate the canvas to the right place and then draw the inner shadow + canvas.translate(bounds.left, bounds.top); + for (int i = 0; i < 4; i++) { Shader shader = shades[i]; Path path = paths[i];
