GeezerVisonThe World Wide Web, restored to 800 pixels of glory. |
| Home|About|Gaming cabinet|Archives|How it works|Starter sites |
GeezerVison is showing raw.githubusercontent.com — raw.githubusercontent.com # Android智能下拉刷新框架-SmartRefreshLayout
[](https://www.apache.org/licenses/LICENSE-2.0)
[](https://android-arsenal.com/details/1/6001)
[](https://bintray.com/scwang90/maven/refresh-layout-kernel/_latestVersion)
[](https://android-arsenal.com/api?level=12)
[](http://www.methodscount.com/?lib=com.scwang.smartrefresh%3ASmartRefreshLayout%3A1.0.4)
## [English](README_EN.md) | 中文
SmartRefreshLayout以打造一个强大,稳定,成熟的下拉刷新框架为目标,并集成各种的炫酷、多样、实用、美观的Header和Footer。
正如名字所说,SmartRefreshLayout是一个“聪明”或者“智能”的下拉刷新布局,由于它的“智能”,它不只是支持所有的View,还支持多层嵌套的视图结构。
它继承自ViewGroup 而不是FrameLayout或LinearLayout,提高了性能。
也吸取了现在流行的各种刷新布局的优点,包括谷歌官方的 [SwipeRefreshLayout](https://developer.android.com/reference/android/support/v4/widget/SwipeRefreshLayout.html),
其他第三方的 [Ultra-Pull-To-Refresh](https://github.com/liaohuqiu/android-Ultra-Pull-To-Refresh)、[TwinklingRefreshLayout](https://github.com/lcodecorex/TwinklingRefreshLayout) 。
还集成了各种炫酷的 Header 和 Footer。
## 国内加速
github 由于你懂的原因,下载速度缓慢,图片也无法查看,可以跳转 [国内镜像](https://gitee.com/scwang90/SmartRefreshLayout)
## 特点功能:
- 支持多点触摸
- 支持淘宝二楼和二级刷新
- 支持嵌套多层的视图结构 Layout (LinearLayout,FrameLayout...)
- 支持所有的 View(AbsListView、RecyclerView、WebView....View)
- 支持自定义并且已经集成了很多炫酷的 Header 和 Footer.
- 支持和 ListView 的无缝同步滚动 和 CoordinatorLayout 的嵌套滚动 .
- 支持自动刷新、自动上拉加载(自动检测列表惯性滚动到底部,而不用手动上拉).
- 支持自定义回弹动画的插值器,实现各种炫酷的动画效果.
- 支持设置主题来适配任何场景的 App,不会出现炫酷但很尴尬的情况.
- 支持设多种滑动方式:平移、拉伸、背后固定、顶层固定、全屏
- 支持所有可滚动视图的越界回弹
- 支持 Header 和 Footer 交换混用
- 支持 AndroidX
- 支持[横向刷新](https://github.com/scwang90/SmartRefreshHorizontal)
## 传送门
- [属性文档](https://github.com/scwang90/SmartRefreshLayout/blob/master/art/md_property.md)
- [常见问题](https://github.com/scwang90/SmartRefreshLayout/blob/master/art/md_faq.md)
- [智能之处](https://github.com/scwang90/SmartRefreshLayout/blob/master/art/md_smart.md)
- [更新日志](https://github.com/scwang90/SmartRefreshLayout/blob/master/art/md_update.md)
- [博客文章](https://segmentfault.com/a/1190000010066071)
- [源码下载](https://github.com/scwang90/SmartRefreshLayout/releases)
- [多点触摸](https://github.com/scwang90/SmartRefreshLayout/blob/master/art/md_multitouch.md)
- [自定义Header](https://github.com/scwang90/SmartRefreshLayout/blob/master/art/md_custom.md)
## Demo
[下载 APK-Demo](https://github.com/scwang90/SmartRefreshLayout/blob/master/art/app-debug.apk)

#### 项目演示
|个人首页|微博列表|
|:---:|:---:|
|||
|餐饮美食|个人中心|
|:---:|:---:|
|||
#### 样式演示 Style
|Delivery|DropBox|
|:---:|:---:|
|||
|[Refresh-your-delivery](https://dribbble.com/shots/2753803-Refresh-your-delivery)|[Dropbox-Refresh](https://dribbble.com/shots/3470499-DropBox-Refresh)|
上面这两个是我自己实现的,下面的是我把github上其它优秀的Header进行的整理和集合还有优化:
|BezierRadar|BezierCircle|
|:---:|:---:|
|||
|[Pull To Refresh](https://dribbble.com/shots/1936194-Pull-To-Refresh)|[Pull Down To Refresh](https://dribbble.com/shots/1797373-Pull-Down-To-Refresh)|
|FlyRefresh|Classics|
|:---:|:---:|
|||
|[FlyRefresh](https://github.com/race604/FlyRefresh)|[ClassicsHeader](#1)|
|Phoenix|Taurus|
|:---:|:---:|
|||
|[Yalantis/Phoenix](https://github.com/Yalantis/Phoenix)|[Yalantis/Taurus](https://github.com/Yalantis/Taurus)
|BattleCity|HitBlock|
|:---:|:---:|
|||
|[FunGame/BattleCity](https://github.com/Hitomis/FunGameRefresh)|[FunGame/HitBlock](https://github.com/Hitomis/FunGameRefresh)
|WaveSwipe|Material|
|:---:|:---:|
|||
|[WaveSwipeRefreshLayout](https://github.com/recruit-lifestyle/WaveSwipeRefreshLayout)|[MaterialHeader](https://developer.android.com/reference/android/support/v4/widget/SwipeRefreshLayout.html)
|StoreHouse|WaterDrop|
|:---:|:---:|
|||
|[CRefreshLayout](https://github.com/cloay/CRefreshLayout)|[WaterDrop](https://github.com/THEONE10211024/WaterDropListView)
看到这么多炫酷的Header,是不是觉得很棒?这时你或许会担心这么多的Header集成在一起,但是平时只会用到一个,是不是要引入很多无用的代码和资源?
V2.x 版本已经把依赖库拆分成8个包啦,用到的时候自行引用就可以啦!
- refresh-layout-kernel 核心必须依赖
- refresh-header-classics 经典刷新头
- refresh-header-radar 雷达刷新头
- refresh-header-falsify 虚拟刷新头
- refresh-header-material 谷歌刷新头
- refresh-header-two-level 二级刷新头
- refresh-footer-ball 球脉冲加载
- refresh-footer-classics 经典加载
## 简单用例
#### 1.在 build.gradle 中添加依赖
[【V1.1.0】](https://github.com/scwang90/SmartRefreshLayout/tree/1.x#%E7%AE%80%E5%8D%95%E7%94%A8%E4%BE%8B) 如果正在使用1.x 版本请调转,当前2.0 版本已经重定制,不支持升级,请在新项目中使用。
V2.x 相对于 V1.x 对包名做了修改如:com.scwang.smartrefresh 改为 com.scwang.smart.refresh。
建议在新项目中使用,如果项目升级,java,xml 中都需要做包名替换,比较麻烦。
但主要改动还是对 Smart 进行分包,减小不必要的依赖,比如不使用二级刷新就不依赖,避免代码冗余。
但是未对 SmartRefreshHeader 分包,里面有十多个Header,建议需要使用哪个就复制哪个的源码到项目中。
当然:大家也可以在讨论区讨论投票,选出里面使用频率比较高的Header,然后单独分离出来。
```
compile 'com.android.support:appcompat-v7:25.3.1' //必须 25.3.1 以上
// 注意:分包之后不会有默认的Header和Footer需要手动添加!还是原来的三种方法!
implementation 'com.scwang.smart:refresh-layout-kernel:2.0.3' //核心必须依赖
implementation 'com.scwang.smart:refresh-header-classics:2.0.3' //经典刷新头
implementation 'com.scwang.smart:refresh-header-radar:2.0.3' //雷达刷新头
implementation 'com.scwang.smart:refresh-header-falsify:2.0.3' //虚拟刷新头
implementation 'com.scwang.smart:refresh-header-material:2.0.3' //谷歌刷新头
implementation 'com.scwang.smart:refresh-header-two-level:2.0.3' //二级刷新头
implementation 'com.scwang.smart:refresh-footer-ball:2.0.3' //球脉冲加载
implementation 'com.scwang.smart:refresh-footer-classics:2.0.3' //经典加载
```
如果使用 AndroidX 先在 gradle.properties 中添加,两行都不能少噢~
```
android.useAndroidX=true
android.enableJetifier=true
```
需要依赖 androidx.appcompat
```
implementation 'androidx.appcompat:appcompat:1.0.0' //必须 1.0.0 以上
implementation 'com.scwang.smart:refresh-layout-kernel:2.0.3' //核心必须依赖
implementation 'com.scwang.smart:refresh-header-classics:2.0.3' //经典刷新头
implementation 'com.scwang.smart:refresh-header-radar:2.0.3' //雷达刷新头
implementation 'com.scwang.smart:refresh-header-falsify:2.0.3' //虚拟刷新头
implementation 'com.scwang.smart:refresh-header-material:2.0.3' //谷歌刷新头
implementation 'com.scwang.smart:refresh-header-two-level:2.0.3' //二级刷新头
implementation 'com.scwang.smart:refresh-footer-ball:2.0.3' //球脉冲加载
implementation 'com.scwang.smart:refresh-footer-classics:2.0.3' //经典加载
```
#### 2.在XML布局文件中添加 SmartRefreshLayout
```xml
|
| You are visitor 01402792 — GeezerVison does not store the pages you look up. Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required. |