类似Lollipop滚动溢出效果的下拉刷新布局:JellyRefreshLayout
yxn5
9年前
类似Lollipop滚动溢出效果的下拉刷新布局。只要将列表控件放在该布局中,就能实现下拉刷新效果。貌似编译需要java8,里面有些表达式是java8的。
使用说明:
Gradle:
repositories { maven { url "https://jitpack.io" } } dependencies { compile 'com.github.allan1st:JellyRefreshLayout:1.0.0' }
Maven:
<repository> <id>jitpack.io</id> <url>https://jitpack.io</url> </repository> <dependency> <groupId>com.github.allan1st</groupId> <artifactId>JellyRefreshLayout</artifactId> <version>1.0.0</version> </dependency>
使用JellyRefreshLayout包裹任意一个RecyclerView/ScrollView/ListView
<uk.co.imallan.jellyrefresh.JellyRefreshLayout xmlns:app="http://schemas.android.com/apk/res-auto" android:text="@string/your_loading_text" android:textColor="@color/your_loading_text_color" app:jellyColor="@color/your_jelly_color" android:layout_width="match_parent" android:layout_height="match_parent"> <ListView android:layout_width="match_parent" android:layout_height="match_parent"/> </uk.co.imallan.jellyrefresh.JellyRefreshLayout>
在触发刷新的时候,回调:
mJellyLayout.setRefreshListener(new JellyRefreshLayout.JellyRefreshListener() { @Override public void onRefresh(final JellyRefreshLayout jellyRefreshLayout) { // your code here } });
如果任务(刷新任务)完成,调用finishrefreshing :
mJellyLayout.finishRefreshing();