界面上拉下拉实现回弹效果
- 当你的界面没有刷新功能的时候可以设置一个回弹效果,使用效果更佳
1. 在build.gradle中设置依赖
implementation 'com.lcodecorex:tkrefreshlayout:1.0.7'
2. 将你想要实现回弹效果的控件包裹起来
- 例如:
<com.lcodecore.tkrefreshlayout.TwinklingRefreshLayout
android:id="@+id/over_scroll_view"
android:layout_width="match_parent"
android:layout_height="match_parent">
<androidx.recyclerview.widget.RecyclerView
android:id="@+id/recommend_list"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#fff4f4f4"
android:overScrollMode="never" />
</com.lcodecore.tkrefreshlayout.TwinklingRefreshLayout>
- 上面是将一个RecycleView包裹了起来。
3. 在程序中找到控件,然后设置。
TwinklingRefreshLayout twinklingRefreshLayout = mRootView.findViewById(R.id.over_scroll_view); //找到控件
twinklingRefreshLayout.setPureScrollModeOn(); //设置回弹效果
好了,回弹效果实现了,快去实现吧。