如何检测用户何时已经到达 NestedScrollView
的末尾并且在当前的滚动尝试中运动正在拉动?
我尝试了一些检测结束滚动的模式,但这与我想要实现的目标相去甚远。
我还发现,我可以重写公共(public)类CoordinatorLayout.Behavior
并使用滚动方法,但是我对当前的@string/appbar_scrolling_view_behavior
很满意,但我不太确定如何继续。
View 结构
<android.support.design.widget.CoordinatorLayout>
<android.support.v4.widget.NestedScrollView
app:layout_behavior="@string/appbar_scrolling_view_behavior" />
<android.support.design.widget.AppBarLayout>
<android.support.design.widget.CollapsingToolbarLayout"
app:layout_scrollFlags="scroll|exitUntilCollapsed|enterAlways" />
</android.support.design.widget.AppBarLayout>
</android.support.design.widget.CoordinatorLayout>
有人熟悉这个问题吗?
最佳答案
您可以像这样检测NestedScrollView的结束
svProduct.getViewTreeObserver()
.addOnScrollChangedListener(() -> {
View view = svProduct.getChildAt(svProduct.getChildCount() - 1);
int diff = (view.getBottom() - (svProduct.getHeight() + svProduct.getScrollY()));
if (diff == 0) {
// reached to bottom
}
});
关于java - 检测垂直滚动已经结束并且用户正在拉动,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48721163/