Awesome Open Source
Awesome Open Source

PullRefreshLayout()

SDK 26.1.0API14,classMDAPI14googleandroid4.0 googlePullRefreshLayoutMinSdk API14.
Stable Version Latest Version MinSdk Methods

ENGLISH

DEMO()

headergif
headergif


![](gif/two_refresh.gif) ![](gif/sliding_down.gif)

![](gif/behavior1.gif) ![](gif/behavior2.gif) ![](gif/behavior3.gif)

,loading

footer
footer

fun header from https://awesomeopensource.com/project/scwang90/SmartRefreshLayout
fun header

ViewPager https://github.com/genius158/PullRefreshLayout/blob/developer/app/src/main/java/com/yan/refreshloadlayouttest/testactivity/CommonActivity5.java

CoordinatorLayout https://github.com/genius158/PullRefreshLayout/blob/master/app/src/main/java/com/yan/refreshloadlayouttest/testactivity/ScrollingActivity.java

1.

:,(ps:),NestedActivity

1.(RecyclerViewNestedScrollViewTextViewListViewScrollerViewwebViewLinearLayout) ()

2.headerfooterheaderfooterheaderheaderfooter8(PLACEHOLDERFOLLOWPLACEHOLDER_FOLLOWCENTERPLACEHOLDER_CENTERFOLLOW_CENTERCENTER_FOLLOWFOLLOW_PLACEHOLDER)onPullChange()

ps:.class

gradle Stable Version

compile 'com.yan:pullrefreshlayout:()'

2.



//--
    refreshLayout.autoRefresh();// 
    refreshLayout.autoRefresh(ture);// ,
    refreshLayout.autoLoading();// 
    refreshLayout.autoLoading(ture);// ,
    
    refreshLayout.setOverScrollDampingRatio(0.35f);//  overscrolloverscroll*0.35 default 0.35F
    refreshLayout.setScrollInterpolator(interpolator);// scroller
    refreshLayout.setAnimationMainInterpolator(interpolator);//  default ViscousInterpolator
    refreshLayout.setAnimationOverScrollInterpolator(interpolator);//  default ViscousInterpolator
            
    refreshLayout.setOverScrollMinDuring(int during);// overscroll default 60
    refreshLayout.setRefreshAnimationDuring(int refreshAnimationDuring);//  default 180
    refreshLayout.setResetAnimationDuring(int resetAnimationDuring);//  default 400
    refreshLayout.setDragDampingRatio(0.6f);// *0.6 default 0.6F
    
    refreshLayout.setOverScrollAdjustValue(1f);// overscroll default 1f ,overscroll
    refreshLayout.setTopOverScrollMaxTriggerOffset(300);// overscroll default 65dp
    refreshLayout.setBottomOverScrollMaxTriggerOffset(300);// overscroll default 65dp
  refreshLayout.setPullUpMaxDistance(300);// (0,0)  
  refreshLayout.setPullDownMaxDistance(300);// (0,0)  

    refreshLayout.setRefreshEnable(false);//  default true
    refreshLayout.setLoadMoreEnable(true);//  default false
    refreshLayout.setTwinkEnable(true);//  default true 
    refreshLayout.setAutoLoadingEnable(true);//  default false
     
    // headerViewfooterViewPullRefreshLayout.OnPullListener
    refreshLayout.setHeaderView(headerView);// headerView
    refreshLayout.setFooterView(footerView);// footerView
    
    refreshLayout.isTwinkEnable();// 
    refreshLayout.isRefreshEnable();// 
    refreshLayout.isLoadMoreEnable();// 
    
    refreshLayout.isDragMoveTrendDown();// 
    
    refreshLayout.isDragUp();// 
    refreshLayout.isDragDown();// 
    refreshLayout.isRefreshing();// 
    refreshLayout.isLoading();// 
    refreshLayout.isOverScrollDown();// 
    refreshLayout.isOverScrollUp();// 
    
    refreshLayout.isDragVertical();// 
    refreshLayout.isDragHorizontal();// 
    refreshLayout.isLayoutDragMoved();// 
    
    refreshLayout.isLayoutMoving();// prl

    refreshLayout.isHoldingTrigger();// 
    refreshLayout.isHoldingFinishTrigger();// 
     
    refreshLayout.getMoveDistance();// refreshlayout
    refreshLayout.getRefreshTriggerDistance();// 
    refreshLayout.getLoadingTriggerDistance();// 
    refreshLayout.getPullUpLimitDistance();// 
    refreshLayout.getPullDownLimitDistance();// 
    refreshLayout.getHeaderView();// headerView
    refreshLayout.getFooterView();// FooterView
    refreshLayout.getTargetView();// TargetView
    
    refreshLayout.setRefreshTriggerDistance(200);// header  
    refreshLayout.setLoadTriggerDistance(200);// footer  
    refreshLayout.setPullUpLimitDistance(400);// 
    refreshLayout.setPullDownLimitDistance(400);// 

    refreshLayout.setTargetView(nestedScrollView);// view
   
    refreshLayout.setDispatchTouchAble(true);//  default true
    refreshLayout.setDispatchPullTouchAble(false);// pullrefreshLayout default true
    refreshLayout.setDispatchChildrenEventAble(false);// View default true
    refreshLayout.setFooterFront(true);// footer default false
    refreshLayout.setHeaderFront(true);// header default false
    refreshLayout.setMoveWithFooter(true);// footer default true
    refreshLayout.setMoveWithContent(true);// view default true
    refreshLayout.setMoveWithHeader(true);// header default true
 
    refreshLayout.cancelAllAnimation();//
    refreshLayout.cancelTouchEvent();//ACTION_CANCEL
  
    refreshLayout.moveChildren(0);// view
    
    refreshLayout.requestPullDisallowInterceptTouchEvent();// touchView
   
    refreshLayout.setOnDragIntercept(PullRefreshLayout.OnDragIntercept);//   BEHAIVOR2
    public static class OnDragIntercept {
        public boolean onHeaderDownIntercept() {// header
            return true;// trueview
        }
        public boolean onFooterUpIntercept() {// footer
            return true;// trueview
        }
    }
    
    /**
    * headerfooter,8
    * FOLLOW,FOLLOW_PLACEHOLDER, PLACEHOLDER_FOLLOW
    * , FOLLOW_CENTER, PLACEHOLDER_CENTER
    * , CENTER, CENTER_FOLLOW
    * , PLACEHOLDER
    */
    refreshLayout.setRefreshShowGravity(RefreshShowHelper.CENTER,RefreshShowHelper.CENTER);
    refreshLayout.setHeaderShowGravity(RefreshShowHelper.CENTER)// header
    refreshLayout.setFooterShowGravity(RefreshShowHelper.CENTER)// footer
    // PullRefreshLayout.OnPullListener
        public interface OnPullListener {
            // 
            void onPullChange(float percent);
            void onPullReset();// 
            void onPullHoldTrigger();// 
            void onPullHoldUnTrigger();// 
            void onPullHolding(); // 
            void onPullFinish();// 
        }
         
    <!-- xml setting -->     
    <com.yan.pullrefreshlayout.PullRefreshLayout xmlns:android="http://schemas.android.com/apk/res/android"
        app:prl_autoLoadingEnable="false"
        app:prl_dragDampingRatio="0.6"
        app:prl_resetAnimationDuring="400"
        app:prl_refreshAnimationDuring="180"
        app:prl_footerShowGravity="follow"
        app:prl_footerViewId="@layout/header_or_footer"
        app:prl_headerViewId="@layout/header_or_footer"
        app:prl_headerClass="com.yan.refreshloadlayouttest.widget.PlaceHolderHeader"
        app:prl_footerClass="com.yan.refreshloadlayouttest.widget.PlaceHolderHeader"
        app:prl_headerShowGravity="statePlaceholder"
        app:prl_loadMoreEnable="true"
        app:prl_loadTriggerDistance="70dp"
        app:prl_overScrollDampingRatio="0.2"
        app:prl_topOverScrollMaxTriggerOffset="65dp"
        app:prl_bottomOverScrollMaxTriggerOffset="70dp"
        app:prl_pullDownMaxDistance="150dp"
        app:prl_pullUpMaxDistance="250dp"
        app:prl_headerFront="true"
        app:prl_footerFront="true"
        app:prl_targetId="@+id/recyclerView"
        app:prl_refreshEnable="true"
        app:prl_refreshTriggerDistance="90dp"
        app:prl_overScrollAdjustValue="1"
        app:prl_twinkEnable="true">     
        
        <!-- recyclerView(View)header--> 
        <com.yan.pullrefreshlayout.PullRefreshLayout xmlns:android="http://schemas.android.com/apk/res/android"
            xmlns:app="http://schemas.android.com/apk/res-auto"
            android:id="@+id/refreshLayout"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            app:prl_targetId="@+id/recyclerView">
        
            <!-- FrameLayout() -->
            <com.yan.refreshloadlayouttest.widget.NestedFrameLayout
                android:layout_width="match_parent"
                android:layout_height="match_parent">
        
                <!--  -->
                <androidx.recyclerview.widget.RecyclerView
                    android:id="@id/recyclerView"
                    android:layout_width="match_parent"
                    android:layout_height="match_parent"
                    android:background="#f1f1f1"
                    android:overScrollMode="never" />
         
                <!-- header -->
                <androidx.cardview.widget.CardView
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content">
        
                    <TextView
                        android:layout_width="match_parent"
                        android:layout_height="46dp"
                        android:gravity="center"
                        android:text="header"
                        android:textSize="18sp" />
                </androidx.cardview.widget.CardView>
        
                <!--  -->
                <TextView
                    android:id="@+id/no_data"
                    android:background="#ffffff"
                    android:gravity="center"
                    android:layout_width="match_parent"
                    android:layout_height="match_parent"
                    android:textColor="#212121"
                    android:textSize="20sp"
                    android:text="no data click to try again"  />
            </com.yan.refreshloadlayouttest.widget.NestedFrameLayout>
        
        </com.yan.pullrefreshlayout.PullRefreshLayout>

3.

version:1.7.3

version:1.7.4 setTargetViewcancel
version:1.7.5

version:1.7.8 onStartNestedScroll()onNestedPreFling()handleAction
version:1.8.5 flingBack


version:2.0.0 SwipeRefreshLayout,
version:2.0.2 viewpager
version:2.0.3 dragState

version:2.0.5
version:2.0.7 qq
version:2.0.9
version:2.0.10 insert methods getHeaderView(),getFooterView),getTargetView()
version:2.1.0 detail adjust
version:2.2.1 add method autoRefresh(int toRefreshDistance),autoLoading(int toLoadDistance)
version:2.2.2
version:2.2.4 header
version:2.2.5 isTargetScrollUpAbleisTargetScrollDownAble
version:2.2.6 fix issue https://github.com/genius158/PullRefreshLayout/issues/25
version:2.2.7
version:3.x androidx
version:3.0.1

4. FAQ(githubissuegithubgithub)

1.VLayout https://github.com/alibaba/vlayout/blob/master/docs/VLayoutFAQ.md


RecyclerView view top 0 VLayout LayoutManager View RecyclerView layoutManager.getChildAt(0) view

    @Override
    public boolean isTargetScrollUpAble() {
     ... 


pjh520 scrollViewViewmargin

5.demo

loading
AVLoadingIndicatorView(https://awesomeopensource.com/project/81813780/AVLoadingIndicatorView)

LICENSE

Copyright 2017 yan

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.

Get A Weekly Email With Trending Projects For These Topics
No Spam. Unsubscribe easily at any time.
Header (405
Pull To Refresh (152
Related Projects