在工作中遇到要实现会弹性滑动的NestedScrollView的需求,于是自己就在NestedScrollView的源码基础上修改得到OverNestedScrollView,使用方法和NestedScrollView一模一样,具体效果如下:
使用例子如下:
xml:
<com.huchenhao.overnestedscrollview.base.OverNestedScrollView xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fillViewport="true"
android:overScrollMode="ifContentScrolls"
android:scrollbarStyle="outsideOverlay"
android:scrollbars="vertical"
>
<android.support.v7.widget.RecyclerView
android:id="@+id/recyclerview"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
</com.huchenhao.overnestedscrollview.base.OverNestedScrollView>
code:
recyclerView.setNestedScrollingEnabled(false);
本文介绍了一种在Android中实现带有弹性滑动效果的NestedScrollView组件——OverNestedScrollView。通过继承并修改NestedScrollView源码,此组件可在RecyclerView等子View中实现平滑的滚动体验。文中提供了XML布局和代码示例,以及GitHub项目链接。
1万+

被折叠的 条评论
为什么被折叠?



