效果如图,下拉后产生一个水滴的效果
1.在你module的build.gradle中添加依赖
dependencies { compile 'com.github.recruit-lifestyle:WaveSwipeRefreshLayout:1.6' }repositories { maven { url "https://jitpack.io" }}
2.在xml中用WaveSwipeRefreshLayout包裹你的控件
android:id="@+id/wave_swipe" android:layout_width="match_parent" android:layout_height="match_parent"> android:id="@+id/recyclerView" android:layout_width="match_parent" android:layout_height="match_parent" />
3.在Java代码中使用
public class MainActivity extends AppCompatActivity { @BindView(R.id.wave_swipe) WaveSwipeRefreshLayout mWaveSwipe; Handler mHandler = new Handler(); @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); ButterKnife.bind(this); //设置小圆圈颜色 mWaveSwipe.setColorSchemeColors(Color.WHITE, Color.YELLOW,Color.RED,Color.GREEN); //设置背景色 mWaveSwipe.setWaveColor(Color.argb(255,63,81,181)); //设置刷新监听 mWaveSwipe.setOnRefreshListener(new WaveSwipeRefreshLayout.OnRefreshListener() { @Override public void onRefresh() { new Thread() { @Override public void run() { SystemClock.sleep(3000); //do something in background mHandler.post(new Runnable() { //stop refreshing @Override public void run() { //... mWaveSwipe.setRefreshing(false);//调用这个方法结束刷新小圆圈的显示 } }); } }.start(); } }); } }
WaveSwipeRefreshLayout控件原地址:
https://github.com/recruit-lifestyle/WaveSwipeRefreshLayout
到这里就结束啦.