Skip to content

一个可以全局随意配置头部的下拉刷新与上拉加载库;

Notifications You must be signed in to change notification settings

luhaoaimama1/ZRefreshLayout

Repository files navigation

中文版文档

ZRefreshLayout

A global random configuration head , drop-down refresh and loadMore library;

Feature

  • support refresh and loadMore
  • support Timeout automatically complete the action
  • support nest scroll
  • support All the View:ImageView,FrameLayout,ListView, GridView, ScrollView, WebView...
  • support Global configuration (HeaderView's configuration is here,so not have xml's property),and Independent changes
  • support auto refresh
  • support header fixed
  • support refresh's Trigger position
  • support drop-down's position map(as IResistance)
  • support add many childs。because extends FrameLayout(not must be one,because more changeful)

JicPack

Add it in your root build.gradle at the end of repositories:

allprojects {
    repositories {
        ...
        maven { url "https://jitpack.io" }
    }
}

Step 2. Add the dependency

compile 'com.github.luhaoaimama1:ZRefreshLayout:Latest release'

not anroidX version compile 'com.github.luhaoaimama1:ZRefreshLayout:1.0.19' branch:notAndroidx

Step 3: you need provide

because compileOnly 'androidx.recyclerview:recyclerview:1.0.0'

UML

Preview

header fixed

Meterial Header与Footer

SinaRefreshHeader与LoadFooter

WaveHead

CircleRefresh Head

引用tuesda的CircleView 主要是为了测试延迟功能

Usage

Global configuration

      Config.build()
            .setHeader(new MeterialHead())
            .setFooter(new MeterialFooter())
            .setResistance(new Damping())
            .writeLog(true)
            .perform();

Independent changes

    refresh.setIHeaderView(new SinaRefreshHeader());

header fixed

    refresh.setHeadPin(ZRefreshLayout.HeadPin.PIN)

auto refresh

    refresh.autoRefresh(haveAnimate)

refresh's listener

refresh complete ,Remember to use:zRefreshLayout.refreshComplete();

      refresh.setPullListener(new ZRefreshLayout.PullListener() {
               @Override
               public void refresh(final ZRefreshLayout zRefreshLayout) {
                   tv.postDelayed(new Runnable() {
                       @Override
                       public void run() {
                           tv.setText("刷新完毕:" + i++);
                           zRefreshLayout.refreshComplete();
                       }
                   }, 500);
               }
           });

loadMore's Listener

if not setLoadMoreListener,not have loadMore feature;

loadMore complete ,Remember to use:zRefreshLayout.loadMoreComplete();

         refresh.setPullListener(new ZRefreshLayout.PullListener() {
                  @Override
                  public void refresh(final ZRefreshLayout zRefreshLayout) {
                      tv.postDelayed(new Runnable() {
                          @Override
                          public void run() {
                              tv.setText("刷新完毕:" + i++);
                              zRefreshLayout.refreshComplete();
                          }
                      }, 500);
                  }
              });

HeadView and FooterView 's custom and More advanced features,please see Wiki Document;;

Reference&Thanks:

https://github.com/lcodecorex/TwinklingRefreshLayout

https://github.com/tuesda/CircleRefreshLayout

https://github.com/android-cjj/Android-MaterialRefreshLayout

https://github.com/desmond1121/Android-Ptr-Comparison

https://github.com/liaohuqiu/android-Ultra-Pull-To-Refresh