From 7cba9876dfb7c5d30360ff6c9d428d867a6ba418 Mon Sep 17 00:00:00 2001 From: teach Date: Wed, 11 Aug 2021 10:28:11 +0800 Subject: [PATCH] =?UTF-8?q?=E6=94=B9bug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ConsecutiveScrollerLayout.java | 24 +++++++++++++++++-- 1 file changed, 22 insertions(+), 2 deletions(-) diff --git a/consecutivescroller/src/main/java/com/donkingliang/consecutivescroller/ConsecutiveScrollerLayout.java b/consecutivescroller/src/main/java/com/donkingliang/consecutivescroller/ConsecutiveScrollerLayout.java index aea5b1b..1bbf9b2 100644 --- a/consecutivescroller/src/main/java/com/donkingliang/consecutivescroller/ConsecutiveScrollerLayout.java +++ b/consecutivescroller/src/main/java/com/donkingliang/consecutivescroller/ConsecutiveScrollerLayout.java @@ -147,8 +147,8 @@ public class ConsecutiveScrollerLayout extends ViewGroup implements ScrollingVie private boolean isPermanent; /** - * 禁用子view的水平滑动,如果ConsecutiveScrollerLayout下没有需要水平滑动的子view,应该把它设置为true - * 为true时,将不会分发滑动事件给子view,而是有ConsecutiveScrollerLayout处理,可以优化ConsecutiveScrollerLayout的滑动 + * 禁用子view的水平滑动,如果ConsecutiveScrollerLayout下没有水平滑动的下级view,应该把它设置为true + * 为true时,将不会分发滑动事件给子view,而是由ConsecutiveScrollerLayout处理,可以优化ConsecutiveScrollerLayout的滑动 */ private boolean disableChildHorizontalScroll; @@ -277,6 +277,9 @@ public ConsecutiveScrollerLayout(Context context, AttributeSet attrs, int defSty mChildHelper = new NestedScrollingChildHelper(this); setNestedScrollingEnabled(true); setChildrenDrawingOrderEnabled(true); + + setMotionEventSplittingEnabled(false); + } @Override @@ -2317,6 +2320,23 @@ public boolean isPermanent() { return isPermanent; } + + public boolean isDisableChildHorizontalScroll() { + return disableChildHorizontalScroll; + } + + /** + * 禁用子view的水平滑动,如果ConsecutiveScrollerLayout下没有水平滑动的下级view,应该把它设置为true + * 为true时,将不会分发滑动事件给子view,而是由ConsecutiveScrollerLayout处理,可以优化ConsecutiveScrollerLayout的滑动 + * 注意:如果你的ConsecutiveScrollerLayout下使用了ViewPager、HorizontalScrollView、水平滑动RecyclerView等, + * 就不要设置disableChildHorizontalScroll为true.因为它会禁止水平滑动 + * + * @param disableChildHorizontalScroll + */ + public void setDisableChildHorizontalScroll(boolean disableChildHorizontalScroll) { + this.disableChildHorizontalScroll = disableChildHorizontalScroll; + } + /** * 设置吸顶view到顶部的偏移量,允许吸顶view在距离顶部offset偏移量的地方吸顶停留。 *