[SmartRefreshLayout ](https://github.com/scwang90/SmartRefreshLayout)
## 特點功能:
- 支持多點觸摸
- 支持嵌套多層的視圖結構 Layout (LinearLayout,FrameLayout...)
- 支持所有的 View(AbsListView、RecyclerView、WebView....View)
- 支持自定義并且已經集成了很多炫酷的 Header 和 Footer.
- 支持和ListView的無縫同步滾動 和 CoordinatorLayout 的嵌套滾動 .
- 支持自動刷新、自動上拉加載(自動檢測列表慣性滾動到底部,而不用手動上拉).
- 支持自定義回彈動畫的插值器,實現各種炫酷的動畫效果.
- 支持設置主題來適配任何場景的App,不會出現炫酷但很尷尬的情況.
- 支持設多種滑動方式:平移、拉伸、背后固定、頂層固定、全屏
- 支持所有可滾動視圖的越界回彈
## 使用:
1. 聲明:
~~~
private RefreshLayout refreshLayout;
~~~
2. 布局xml:
~~~
<com.scwang.smartrefresh.layout.SmartRefreshLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/refreshLayout"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context="com.canyou.redmine.ui.fragment.ProjectsFragment">
<android.support.v7.widget.RecyclerView
android:id="@+id/rv_projects"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@android:color/darker_gray" />
</com.scwang.smartrefresh.layout.SmartRefreshLayout>
~~~
3. 綁定:
~~~
refreshLayout = view.findViewById(R.id.refreshLayout);
~~~
4. 下拉刷新:
~~~
refreshLayout.setOnRefreshListener(new OnRefreshListener() {
@Override
public void onRefresh(RefreshLayout refreshlayout) {
pageIndex = 0;
getProjects(pageIndex, pageSize);
}
});
~~~
5. 上拉加載更多:
~~~
refreshLayout.setOnLoadmoreListener(new OnLoadmoreListener() {
@Override
public void onLoadmore(RefreshLayout refreshlayout) {
pageIndex++;
getProjects(pageIndex, pageSize);
}
});
~~~
6. 開始刷新:
~~~
refreshLayout.autoRefresh();
~~~
7. 結束刷新:
~~~
refreshLayout.finishRefresh();
refreshLayout.finishLoadmore(true);
~~~