Skip to content

Latest commit

History

History
251 lines (199 loc) · 11.7 KB

File metadata and controls

251 lines (199 loc) · 11.7 KB

Android Smart Refresh Layout Framework

LicenseArsenalJcenterMinSdkMethods

English | 中文

As the name says, SmartRefreshLayout is a "smart" or "intelligent" pull-down refresh layout,because of its "smart", it does not just support all the Views , but also support multi-layered nested view structures.
It extends from ViewGroup rather than FrameLayout or LinearLayout, this not only improves its performance, but also enables it to absorb the advantages of various refresh layouts in fashion now,Including Google official SwipeRefreshLayoutTwinklingRefreshLayoutUltra-Pull-To-Refresh. Also it integrates various cool Headers and Footers.
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).

Gateway

Demo

Download APK-Demo

Practical

WeiboFeedlist
RepastProfile

Style

StyleDeliveryDropbox
Demo
DesignRefresh-your-deliveryDropbox-Refresh

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

StyleBezierRadarBezierCircle
Demo
FromTwinklingRefreshLayoutPull Down To Refresh
StyleFlyRefreshClassics
Demo
FromFlyRefreshClassicsHeader
StylePhoenixTaurus
Demo
FromYalantis/PhoenixYalantis/Taurus
StyleBattleCityHitBlock
Demo
FromFunGame/BattleCityFunGame/HitBlock
StyleWaveSwipeMaterial
Demo
FromWaveSwipeRefreshLayoutMaterialHeader
StyleStoreHouseWaterDrop
Demo
FromUltra-Pull-To-RefreshWaterDrop

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 three packages, when used to reference their own it!

  • SmartRefreshLayout: The core to realize,Bring ClassicsHeader and BezierRadarHeader.
  • SmartRefreshHeader: Integration of various kinds of the Header.
  • SmartRefreshFooter: Integration of various kinds of the Footer.

Usage

1.Add a gradle dependency.

compile 'com.scwang.smartrefresh:SmartRefreshLayout:1.0.4-4'
compile 'com.scwang.smartrefresh:SmartRefreshHeader:1.0.4-4'//If you use the special Header
compile 'com.android.support:appcompat-v7:25.3.1'
compile 'com.android.support:design:25.3.1'//(Not necessary,Can solve problems that cannot be previewed)

2.Add SmartRefreshLayout in the layout xml.

<?xml version="1.0" encoding="utf-8"?>
<com.scwang.smartrefresh.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.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.smartrefresh.layout.SmartRefreshLayout>

3.Coding in the Activity or Fragment.

RefreshLayoutrefreshLayout = (RefreshLayout)findViewById(R.id.refreshLayout);
refreshLayout.setOnRefreshListener(newOnRefreshListener() {
@OverridepublicvoidonRefresh(RefreshLayoutrefreshlayout) {
refreshlayout.finishRefresh(2000);
}
});
refreshLayout.setOnLoadmoreListener(newOnLoadmoreListener() {
@OverridepublicvoidonLoadmore(RefreshLayoutrefreshlayout) {
refreshlayout.finishLoadmore(2000);
}
});

Use the specified Header and Footer

1.Global settings

publicclassAppextendsApplication {
publicvoidonCreate() {
super.onCreate();
SmartRefreshLayout.setDefaultRefreshHeaderCreater(newDefaultRefreshHeaderCreater() {
@OverridepublicRefreshHeadercreateRefreshHeader(Contextcontext, RefreshLayoutlayout) {
returnnewClassicsHeader(context).setSpinnerStyle(SpinnerStyle.Translate);
}
});
SmartRefreshLayout.setDefaultRefreshFooterCreater(newDefaultRefreshFooterCreater() {
@OverridepublicRefreshFootercreateRefreshFooter(Contextcontext, RefreshLayoutlayout) {
returnnewClassicsFooter(context).setSpinnerStyle(SpinnerStyle.Translate);
}
});
}
}

Note: this method is the lowest priority.

2.Specified in the XML layout file

<com.scwang.smartrefresh.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-->
<com.scwang.smartrefresh.layout.header.ClassicsHeader
android:layout_width="match_parent"android:layout_height="wrap_content"/>
<TextViewandroid:layout_width="match_parent"android:layout_height="match_parent"android:padding="@dimen/padding_common"android:background="@android:color/white"android:text="@string/description_define_in_xml"/>
<com.scwang.smartrefresh.layout.footer.ClassicsFooter
android:layout_width="match_parent"android:layout_height="wrap_content"/>
</com.scwang.smartrefresh.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

finalRefreshLayoutrefreshLayout = (RefreshLayout) findViewById(R.id.refreshLayout);
refreshLayout.setRefreshHeader(newMaterialHeader(this).setShowBezierWave(true));
refreshLayout.setRefreshFooter(newBallPulseFooter(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 scan the qr code below to ask the author to drink a cup of coffee.

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

Discuss

Contact me: scwang90@hotmail.com

Thanks

SwipeRefreshLayout
TwinklingRefreshLayout
android-Ultra-Pull-To-Refresh

License

Copyright 2017 scwang90
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
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.