From d5465a9a0a840f7e759bb8fb6679b01017eb3d05 Mon Sep 17 00:00:00 2001 From: Jiaqi Wu Date: Thu, 19 Jul 2018 17:15:32 -0700 Subject: [PATCH] Fix ReactHorizontalScrollView overflow issue Summary: Fix ReactHorizontalScrollView so that its children won't overflow. (Task: https://our.intern.facebook.com/intern/tasks/?t=31128239) Reviewed By: achen1 Differential Revision: D8923947 fbshipit-source-id: 56c36b25c29a87a306d92544273603d0d086edc0 --- .../react/views/scroll/ReactHorizontalScrollView.java | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/ReactAndroid/src/main/java/com/facebook/react/views/scroll/ReactHorizontalScrollView.java b/ReactAndroid/src/main/java/com/facebook/react/views/scroll/ReactHorizontalScrollView.java index 90b9d1fc4d3a9c..ba6ff876c2b7dd 100644 --- a/ReactAndroid/src/main/java/com/facebook/react/views/scroll/ReactHorizontalScrollView.java +++ b/ReactAndroid/src/main/java/com/facebook/react/views/scroll/ReactHorizontalScrollView.java @@ -38,6 +38,7 @@ public class ReactHorizontalScrollView extends HorizontalScrollView implements private final OnScrollDispatchHelper mOnScrollDispatchHelper = new OnScrollDispatchHelper(); private final VelocityHelper mVelocityHelper = new VelocityHelper(); + private final Rect mRect = new Rect(); private boolean mActivelyScrolling; private @Nullable Rect mClippingRect; @@ -102,6 +103,13 @@ public void flashScrollIndicators() { awakenScrollBars(); } + @Override + protected void onDraw(Canvas canvas) { + getDrawingRect(mRect); + canvas.clipRect(mRect); + super.onDraw(canvas); + } + @Override protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) { MeasureSpecAssertions.assertExplicitMeasureSpec(widthMeasureSpec, heightMeasureSpec);