Giter Site home page Giter Site logo

szn0212 / qrefreshlayout Goto Github PK

View Code? Open in Web Editor NEW

This project forked from zhangxq/qrefreshlayout

1.0 1.0 0.0 1.15 MB

下拉刷新,上拉加载更多,自动加载更多,用法同SwipeRefreshLayout,兼容所有view,兼容nested滚动

Home Page: https://github.com/zhangxq/QRefreshLayout

Java 100.00%

qrefreshlayout's Introduction

QRefreshLayout

下拉刷新,上拉加载更多,自动加载更多,用法同SwipeRefreshLayout,兼容所有view,兼容nested滚动

使用方式

allprojects {
  repositories {
    ...
    maven { url 'https://jitpack.io' }
  }
}
dependencies {
  implementation 'com.github.zhangxq:QRefreshLayout:1.0.2'
}
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical">

    <com.zhangxq.refreshlayout.RefreshLayout
        android:id="@+id/refreshLayout"
        android:layout_width="match_parent"
        android:layout_height="match_parent">

        <android.support.v7.widget.RecyclerView
            android:id="@+id/recyclerView"
            android:layout_width="match_parent"
            android:layout_height="match_parent" />
    </com.zhangxq.refreshlayout.RefreshLayout>
</LinearLayout>
refreshLayout.setOnRefreshListener(this);
refreshLayout.setOnLoadListener(this);

接口说明

名称 功能
setOnRefreshListener 设置下拉刷新监听
setOnLoadListener 设置加载更多监听
setRefreshing 打开或者关闭下拉刷新动画
setLoading 打开或关闭加载更多动画
setColorSchemeResources setColorSchemeColors 设置默认下拉刷新进度圈颜色
setProgressBackgroundColorSchemeResource setProgressBackgroundColorSchemeResource 设置默认下拉刷新进度圈背景颜色
setRefreshView 设置下拉刷新view
setLoadView 设置加载更多view
setLoadEnable 设置加载更多开关, setOnLoadListener调用后默认开启
setAutoLoad 设置自动加载更多开关,setOnLoadListener调用后默认开启

自定义下拉刷新和加载更多view

setRefreshView 和 setLoadView 两个方法用于接收用户自定义的下拉刷新和加载更多动画view,参数都是接收一个继承自RefreshView的子类,RefreshView实现了一个Refresh接口,代码如下:

public interface Refresh {
    /**
     * 手指拖动中
     *
     * @param dragDistance      手指拖动的距离
     * @param distanceToRefresh 下拉到触发刷新位置的距离
     * @param totalDistance     总的下拉空间
     */
    void setHeight(float dragDistance, float distanceToRefresh, float totalDistance);

    /**
     * 触发刷新
     */
    void setRefresh();

    /**
     * 下拉刷新
     */
    void setPullToRefresh();

    /**
     * 释放即可刷新
     */
    void setRefeaseToRefresh();
}

可以看到,接口提供了三个个回调方法,对应与下拉或上拉过程中常用的三个时间点,setHeight方法提供了手指拖动的距离,方便用户处理拖动动画。 继承RefreshView覆盖这四个方法,就可以方便得实现自己想要的动画效果。

qrefreshlayout's People

Contributors

zhangxq avatar

Stargazers

szn0212 avatar

Watchers

James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.