Need help with TwinklingRefreshLayout?
Click the “chat” button below for chat support from the developer who created it, or find similar developers for support.

About the developer

3.9K Stars 674 Forks Apache License 2.0 71 Commits 109 Opened issues


RefreshLayout that support for OverScroll and better than iOS. 支持下拉刷新和上拉加载的RefreshLayout,自带越界回弹效果,支持RecyclerView,AbsListView,ScrollView,WebView

Services available


Need anything else?

Contributors list

# 31,451
37 commits




TwinklingRefreshLayout extended the thoughts of SwipeRefreshLayout,using a ViewGroup to include a list of Views, to maintain its low coupling and high versatility. Follows are its main features.

  • New overscroll animations, running smoothly, much better than iOS.
  • Support RecyclerView, ScrollView, AbsListView, WebView and so on.
  • Support to load more.
  • Default support cross-border rebound.
  • You can open a pure bounds rebound mode.
  • Lots of methods in the class OnRefreshListener.
  • It provides an interface to the callback during the sliding coefficient. Personalized offer good support.
  • NestedScroll,CoordinatorLayout

Any View is supported.


Download Demo

You can download these Videos for more details.


1.Add a gradle dependency.

compile 'com.lcodecorex:tkrefreshlayout:1.0.7'

2.Add TwinklingRefreshLayout in the layout xml.

< android:id="@+id/recyclerview" android:layout_width="match_parent" android:layout_height="match_parent" android:overscrollmode="never" android:background="#fff"></>


To get better effect, you'd better add code

to the childView.

3.Coding in the Activity or Fragment.

Change of state need to be manually controlled.
refreshLayout.setOnRefreshListener(new RefreshListenerAdapter(){
            public void onRefresh(final TwinklingRefreshLayout refreshLayout) {
                new Handler().postDelayed(new Runnable() {
                    public void run() {

        public void onLoadMore(final TwinklingRefreshLayout refreshLayout) {
            new Handler().postDelayed(new Runnable() {
                public void run() {

Use finishRefreshing() method to end refresh, finishLoadmore() method to end load more. OnRefreshListener there are other methods, you can choose need to override.

And if you want you refresh automatically, call the method startRefresh().

  • setMaxHeadHeight is used To set the maximum height of the head can be stretched.
  • setHeaderHeight is used to set the standard head height.
  • setMaxBottomHeight.
  • setBottomHeight is used to set the Bottom height.
  • setOverScrollHeight is used to set the max height of overscroll.

And now dp value is supported.


Flexible settings for whether to disable the pulling-down mode.

setHeaderView(IHeaderView headerView)、setBottomView(IBottomView bottomView)


Whether to allow overscroll mode, opened by default.


Whether to allow the display refresh control on overscrolling, the default is true.


To open the pure overscroll mode so that refreshView would gone permanently.


if open the loadmore mode after overscrolling bottom automatically.


Allow you to add a view fixed on the top.


Make refresh-animation like SwipeRefreshLayout.

setTargetView(View view)

Set the target view that you can scroll.


static methods aims to set a default header/footer in a/an Application/Activity.


  • trmaxhead_height - Flexible head height
  • trheadheight - Head height
  • trmaxbottom_height
  • trbottomheight - Bottom height
  • troverscrollheight - OverScroll Height
  • trenablerefresh - default is true
  • trenableloadmore - default is true
  • trpureScrollModeon - default is false
  • troverscrolltop_show - default is true
  • troverscrollbottom_show - default is true
  • trenableoverscroll - default is true.
  • tr_floatRefresh - open the float-refresh mode.
  • tr_autoLoadMore
  • trenablekeepIView - default is true.
  • tr_showRefreshingWhenOverScroll - default is true.
  • tr_showLoadingWhenOverScroll - default is true.



  • onPullingDown(TwinklingRefreshLayout refreshLayout, float fraction)
  • onPullingUp(TwinklingRefreshLayout refreshLayout, float fraction)
  • onPullDownReleasing(TwinklingRefreshLayout refreshLayout, float fraction)
  • onPullUpReleasing(TwinklingRefreshLayout refreshLayout, float fraction)
  • onRefresh(TwinklingRefreshLayout refreshLayout)
  • onLoadMore(TwinklingRefreshLayout refreshLayout)

fraction = currentMoveHeight/headHeight OR (fraction = currentMoveHeight/bottomHeight).

3.Header and Footer

BezierLayout(pic 4)
  • setWaveColor
  • setRippleColor
GoogleDotView(pic 5)
SinaRefreshView(pic 3)
  • setArrowResource
  • setTextColor
  • setPullDownStr
  • setReleaseRefreshStr
  • setRefreshingStr
ProgressLayout(SwipeRefreshLayout pic 6)
  • setProgressBackgroundColorSchemeResource(@ColorRes int colorRes)
  • setProgressBackgroundColorSchemeColor(@ColorInt int color)
  • setColorSchemeResources(@ColorRes int... colorResIds)


BallPulseView(pic 2)
  • setNormalColor(@ColorInt int color)
  • setAnimatingColor(@ColorInt int color)
LoadingView(pic 3)

Here is more animations.AVLoadingIndicatorView

3.Personalize the Header and Footer.

The Header needs to implement IHeaderView interface and Footer in in the same way(IBottomView). ```java public interface IHeaderView { View getView();

void onPullingDown(float fraction,float maxHeadHeight,float headHeight);

void onPullReleasing(float fraction,float maxHeadHeight,float headHeight);

void startAnim(float maxHeadHeight,float headHeight);

void reset();

} ```

getView() method is not allow to return null.

Let's implement a simple refresh dynamic efficiency.

1.Define SinaRefreshHeader extended from FrameLayout and implement IHeaderView interface.

2.Return this in the method getView().

3.Inflate and find Views in the layout xml.

void init() {
        if (rootView == null) {
            rootView = View.inflate(getContext(), R.layout.view_sinaheader, null);
            refreshArrow = (ImageView) rootView.findViewById(;
            refreshTextView = (TextView) rootView.findViewById(;
            loadingView = (ImageView) rootView.findViewById(;

4.Override some methods. ```java @Override public void onPullingDown(float fraction, float maxHeadHeight, float headHeight) { if (fraction < 1f) refreshTextView.setText(pullDownStr); if (fraction > 1f) refreshTextView.setText(releaseRefreshStr); refreshArrow.setRotation(fraction * headHeight / maxHeadHeight * 180);


@Override public void onPullReleasing(float fraction, float maxHeadHeight, float headHeight) { if (fraction < 1f) { refreshTextView.setText(pullDownStr); refreshArrow.setRotation(fraction * headHeight / maxHeadHeight * 180); if (refreshArrow.getVisibility() == GONE) { refreshArrow.setVisibility(VISIBLE); loadingView.setVisibility(GONE); } } }

@Override public void startAnim(float maxHeadHeight, float headHeight) { refreshTextView.setText(refreshingStr); refreshArrow.setVisibility(GONE); loadingView.setVisibility(VISIBLE); }

@Override public void onFinish(OnAnimEndListener listener) { listener.onAnimEnd(); }

5.layout xml.


<imageview android:id="@+id/iv_loading" android:visibility="gone" android:layout_width="34dp" android:layout_height="34dp" android:src="@drawable/anim_loading_view"></imageview>

<textview android:id="@+id/tv" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_marginleft="16dp" android:textsize="16sp" android:text="pull down to refresh"></textview>

Pay attention to the using of the parameter

. Such as the code above
refreshArrow.setRotation(fraction * headHeight / maxHeadHeight * 180)
fraction * headHeight
is the translationY of the Head and 180 is the angle the arrow would rotate,so that we can make the arrow rotate 180 degrees when the translationY is come to the maxHeadHeight.

onPullingDown/onPullingUp onPullReleasing startAnim - be called automatically after the method onRefresh/onLoadMore is called.

Congratulations! Simple to use and simple to Personalise.(To see a more simple example. TextHeaderView(pic 4))。


TwinklingRefreshLayout Nested CoordinatorLayout

---layout ```xml <?xml version="1.0" encoding="utf-8"?>

< android:id="@+id/appbar_layout" android:layout_width="match_parent" android:layout_height="wrap_content" android:clipchildren="false">



< android:id="@+id/recyclerview" android:layout_width="match_parent" android:layout_height="match_parent" app:layout_behavior="@string/appbar_scrolling_view_behavior"></>



--- code1

Find the RecyclerView/ListView.

--- code2

AppBarLayout appBarLayout = (AppBarLayout) findViewById(;
appBarLayout.addOnOffsetChangedListener(new AppBarLayout.OnOffsetChangedListener() {
    public void onOffsetChanged(AppBarLayout appBarLayout, int verticalOffset) {
        if (verticalOffset >= 0) {
        } else {

CoordinatorLayout nested TwinklingRefreshLayout

--- layout ```xml <?xml version="1.0" encoding="utf-8"?>

< android:id="@+id/recyclerview" android:layout_width="match_parent" android:layout_height="match_parent"></>



Pay attention to
layoutbehavior="@string/appbarscrollingviewbehavior"` for TwinklingRefreshLayout.

ps:Contact me: [email protected] QQ group: 202640706

If you like this library, you can donate me. Buy me a coffee!

Update Logs


  • NestedScroll,CoordinateLayout
  • Any View
  • Keep state when refreshing/loading.


  • Repair memory leaks of customized Views.
  • remove the dependence of AVLoadingIndicatorView.
  • Fix bugs of OverScroll when TargetView scrolls at the top/bottom.
  • Repair bugs of touching,scroll-event listeners.
  • Optimization of interface flicker problems after load-more.

v1.05 Emergency Fix

  • Fix the bug of setAutoLoadMore().
  • Fix the bug that FixedHeader covered the first item of listview.
  • Add onRefreshCanceled()/onLoadmoreCanceled() for RefreshListenerAdapter.


  • Refactor the code.
  • Make animations smoothly.
  • Add support to Fixed Header.
  • Add support to float refresh mode.
  • IHeadView.onFinish(animEndListener) -> Available to run animations before finishRefresh.


  • more attributes.
  • Fix the NullPointerException bug in Fragment.
  • Fix the Sliding conflict.


Copyright 2016 lcodecorex

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

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.

We use cookies. If you continue to browse the site, you agree to the use of cookies. For more information on our use of cookies please see our Privacy Policy.