树朾 / SmartRefreshLayout .gitee-modal { width: 500px !important; }

Explore and code with more than 6 million developers，Free private repositories ！：）

SmartRefreshLayout

English | 中文

SmartRefreshLayout's goal is to build a strong, stable and mature pull-down refresh layout framework, and to integrate all kinds of cool, diverse, practical and beautiful Headers and Footers.

Features

• Support multi-touch.
• Support multi-layered nested view structures.
• Support all the Views（AbsListView、RecyclerView、WebView....View）
• Support customizing Headers and Footers, and has integrated a lot of cool Headers and Footers.
• Support synchronous scrolling with ListView and NestedScrolling with CoordinatorLayout.
• Support automatically refresh, automatically pull-up loading (automatically detect list inertance and scroll to the bottom without having to manually pull).
• Support customizing rebound animation interpolator, to achieve a variety of cool animation effects.
• Support setting a theme to fit any scene of App, it won't appear a cool but very awkward situation.
• Support setting a variety of transformations (Translation, stretching, behind fixed, top fixed, full screen view) for Headers and Footers.
• Support rewrite and extension, internal implementation without private methods and fields.
• Support automatically cross-border rebound for all rolling Views (ListView、RecyclerView、ScrollView、WebView...View).
• Support the interchange of Header and Footer
• Support AndroidX
• Support HorizontalRefresh

Demo

Weibo FeedList
Repast Profile

Style

Style Delivery DropBox
Demo
Design Refresh-your-delivery DropBox-Refresh

The two above headers are implemented by myself, The following headers are collected and optimized from excellent Headers on github

Demo
From TwinklingRefreshLayout Pull Down To Refresh
Style FlyRefresh Classics
Demo
Style Phoenix Taurus
Demo
From Yalantis/Phoenix Yalantis/Taurus
Style BattleCity HitBlock
Demo
From FunGame/BattleCity FunGame/HitBlock
Style WaveSwipe Material
Demo
Style StoreHouse WaterDrop
Demo
From Ultra-Pull-To-Refresh WaterDrop

See so many cool headers, is not it feel great? At this point you may be worried that so many headers together, but usually only use one, is not to introduce a lot of useless code and resources?
Please rest assured that I have divided it into eight packages, when used to reference their own it!

• refresh-layout-kernel core
• refresh-footer-ball BallPulseFooter
• refresh-footer-classics ClassicsFooter

Usage

V 2.x changed the package name relative to 1.x, such as com.scwang.smartrefresh to com.scwang.smart.refresh. It is suggested that in the new project, if the old project is upgraded, the package name should be replaced, which is more troublesome. But the main change is to subcontract SmartRefreshLayout to reduce unnecessary dependencies and avoid code redundancy. However, there is no subcontracting to SmartRefreshHeader. There are more than ten headers in it. It is recommended that you copy the source code into the project whenever you need to use it.

// Note: There will be no default Header and Footer after subcontracting. It needs to be added manually!
implementation  'com.scwang.smart:refresh-layout-kernel:2.0.1'      //core
implementation  'com.scwang.smart:refresh-footer-ball:2.0.1'        //BallPulseFooter
implementation  'com.scwang.smart:refresh-footer-classics:2.0.1'    //ClassicsFooter


android.useAndroidX=true
android.enableJetifier=true

2.Add SmartRefreshLayout in the layout xml.

<?xml version="1.0" encoding="utf-8"?>
<com.scwang.smart.refresh.layout.SmartRefreshLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/refreshLayout"
android:layout_width="match_parent"
android:layout_height="match_parent">
android:layout_width="match_parent"
android:layout_height="wrap_content"/>
<android.support.v7.widget.RecyclerView
android:id="@+id/recyclerView"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:overScrollMode="never"
android:background="#fff" />
<com.scwang.smart.refresh.footer.ClassicsFooter
android:layout_width="match_parent"
android:layout_height="wrap_content"/>
</com.scwang.smart.refresh.layout.SmartRefreshLayout>

3.Coding in the Activity or Fragment.

RefreshLayout refreshLayout = (RefreshLayout)findViewById(R.id.refreshLayout);
refreshLayout.setRefreshFooter(new ClassicsFooter(this));
refreshLayout.setOnRefreshListener(new OnRefreshListener() {
@Override
public void onRefresh(RefreshLayout refreshlayout) {
refreshlayout.finishRefresh(2000/*,false*/);//传入false表示刷新失败
}
});
@Override
}
});

Use the specified Header and Footer

1.Global settings

public class App extends Application {
public void onCreate() {
super.onCreate();
@Override
}
});
SmartRefreshLayout.setDefaultRefreshFooterCreator(new DefaultRefreshFooterCreator() {
@Override
public RefreshFooter createRefreshFooter(Context context, RefreshLayout layout) {
return new ClassicsFooter(context).setSpinnerStyle(SpinnerStyle.Translate);
}
});
}
}

Note: this method is the lowest priority.

2.Specified in the XML layout file

<com.scwang.smart.refresh.layout.SmartRefreshLayout
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/refreshLayout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#444444"
app:srlPrimaryColor="#444444"
app:srlAccentColor="@android:color/white"
app:srlEnablePreviewInEditMode="true">
<!--srlAccentColor and srlPrimaryColor, Will change the Header and Footer theme colors-->
<!--srlEnablePreviewInEditMode, Can open and close the preview function-->
android:layout_width="match_parent"
android:layout_height="wrap_content"/>
<TextView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@android:color/white"
android:text="@string/description_define_in_xml"/>
<com.scwang.smart.refresh.footer.ClassicsFooter
android:layout_width="match_parent"
android:layout_height="wrap_content"/>
</com.scwang.smart.refresh.layout.SmartRefreshLayout>

Note: this method of priority is medium。When using this method, the Android Studio will have preview effect, the following figure:

But don't worry, just a preview effect, run only the drop-down will appear.

3.Specified in the java code

final RefreshLayout refreshLayout = (RefreshLayout) findViewById(R.id.refreshLayout);
refreshLayout.setRefreshFooter(new BallPulseFooter(this).setSpinnerStyle(SpinnerStyle.Scale));

ProGuard

This library does't use serialization and deserialization, JNI, reflection, so there is no need to add confusing filtering code, and it has been confusing tests pass, if you after the confusion in the use of the project appear problem, please inform me.

Donate

If you like this library's design, feel it help to you, you can point the upper right corner "Star" support Thank you! ^ _ ^ You can also click the PayPal below to ask the author to drink a cup of coffee.

If in the donation message note name, it will be record to the list
Donation list

Discuss

Contact me: scwang90@hotmail.com

Other Works

Copyright 2017 scwang90

you may not use this file except in compliance with the License.
You may obtain a copy of the License at

Unless required by applicable law or agreed to in writing, software
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.

Android and 2 more languages
Apache-2.0

No release

Activities

Android
1
https://git.oschina.net/scwang90/SmartRefreshLayout.git
git@git.oschina.net:scwang90/SmartRefreshLayout.git
scwang90
SmartRefreshLayout
SmartRefreshLayout
master