一.导入依赖
//依赖
implementation ‘com.scwang.smartrefresh:SmartRefreshLayout:1.1.0-alpha-28’
implementation ‘com.scwang.smartrefresh:SmartRefreshHeader:1.1.0-alpha-28’
//没有使用特殊Header,可以不加这行
implementation ‘com.android.support:appcompat-v7:25.3.1’//版本 23以上(必须)
1.Activity布局
<com.scwang.smartrefresh.layout.SmartRefreshLayout
android:layout_width="match_parent"
android:id="@+id/smart"
android:layout_height="match_parent">
<com.scwang.smartrefresh.layout.header.ClassicsHeader
android:layout_width="match_parent"
android:layout_height="match_parent"
></com.scwang.smartrefresh.layout.header.ClassicsHeader>
<androidx.recyclerview.widget.RecyclerView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="@+id/rec"></androidx.recyclerview.widget.RecyclerView>
<com.scwang.smartrefresh.layout.footer.ClassicsFooter
android:layout_width="match_parent"
android:layout_height="wrap_content"></com.scwang.smartrefresh.layout.footer.ClassicsFooter>
</com.scwang.smartrefresh.layout.SmartRefreshLayout>
2.java代码:
样式里面加一个 new就可以了
SmartRefreshLayout smartRefreshLayout= findViewById(R.id.smart);
smartRefreshLayout.setRefreshHeader(new DeliveryHeader(this))
二.相关的样式
1.//设置 Header 为 各种有趣的样式
```javascript
refreshLayout.setRefreshHeader(DeliveryHeader(this))
//设置 Header 为 掉落盒子 样式
refreshLayout.setRefreshHeader(DropBoxHeader(this))
//官方 样式
refreshLayout.setRefreshHeader(MaterialHeader(this))
//苹果水滴 样式
refreshLayout.setRefreshHeader(WaterDropHeader(this))
//经典样式
refreshLayout.setRefreshHeader(ClassicsHeader(this))
//弹出文字 样式
refreshLayout.setRefreshHeader(StoreHouseHeader(this))
//弹出圆圈 样式
refreshLayout.setRefreshHeader(BezierCircleHeader(this))
//贝塞尔雷达 样式 ,setEnableHorizontalDrag设置启用水平拖动
refreshLayout.setRefreshHeader(BezierRadarHeader(this))
//弹出水滴 样式 ,水滴需要一半屏幕高度,慎用
refreshLayout.setRefreshHeader(WaveSwipeHeader(this))
//淘宝二楼 样式
refreshLayout.setRefreshHeader(TwoLevelHeader(this))
//坦克游戏 样式
refreshLayout.setRefreshHeader(FunGameBattleCityHeader(this))
//打砖块游戏 样式
refreshLayout.setRefreshHeader(FunGameHitBlockHeader(this))
//金色校园 样式
refreshLayout.setRefreshHeader(PhoenixHeader(this))
//冲上云霄 样式
refreshLayout.setRefreshHeader(TaurusHeader(this))
2.运行效果
就不一一展示了,各位可以测试一下