Top Related Projects
🔥下拉刷新、上拉加载、二级刷新、淘宝二楼、RefreshLayout、OverScroll,Android智能下拉刷新框架,支持越界回弹、越界拖动,具有极强的扩展性,集成了几十种炫酷的Header和 Footer。
Ultra Pull to Refresh for Android. Support all the views.
Phoenix Pull-to-Refresh
DEPRECATED
A reusable pull-to-refresh and pull-to-loadmore widget
A pull to refresh layout for android, the RecyclerRefreshLayout is based on the SwipeRefreshLayout. support all the views, highly customizable, code simplicity, etc. really a practical RefreshLayout!
Quick Overview
SmoothRefreshLayout is an Android library that provides a customizable pull-to-refresh layout for implementing smooth scrolling and refreshing effects in Android applications. It supports both vertical and horizontal orientations, and offers a wide range of customization options for refresh indicators and animations.
Pros
- Highly customizable with support for various refresh indicators and animations
- Supports both vertical and horizontal orientations
- Smooth scrolling and refreshing effects
- Compatible with most scrollable views (e.g., ListView, RecyclerView, ScrollView)
Cons
- Steeper learning curve compared to simpler pull-to-refresh libraries
- May require more setup and configuration for complex use cases
- Documentation could be more comprehensive for advanced features
- Some reported issues with nested scrolling in certain scenarios
Code Examples
- Basic implementation with a ListView:
val refreshLayout = findViewById<SmoothRefreshLayout>(R.id.refresh_layout)
val listView = findViewById<ListView>(R.id.list_view)
refreshLayout.setOnRefreshListener {
// Perform refresh operation
refreshLayout.refreshComplete()
}
refreshLayout.autoRefresh() // Trigger refresh programmatically
- Customizing the refresh header:
val refreshLayout = findViewById<SmoothRefreshLayout>(R.id.refresh_layout)
val customHeader = CustomRefreshHeader(context)
refreshLayout.setHeaderView(customHeader)
refreshLayout.setEnableHeaderDrawerStyle(true)
refreshLayout.setHeaderHeight(100f)
- Implementing horizontal refresh:
val refreshLayout = findViewById<SmoothRefreshLayout>(R.id.refresh_layout)
refreshLayout.setLayoutOrientation(SmoothRefreshLayout.HORIZONTAL)
refreshLayout.setEnableFooterDrawerStyle(true)
refreshLayout.setFooterView(CustomRefreshFooter(context))
Getting Started
To use SmoothRefreshLayout in your Android project:
-
Add the dependency to your app's
build.gradle
file:implementation 'com.github.dkzwm:SmoothRefreshLayout:1.6.0'
-
Add the SmoothRefreshLayout to your layout XML:
<me.dkzwm.widget.srl.SmoothRefreshLayout android:id="@+id/refresh_layout" android:layout_width="match_parent" android:layout_height="match_parent"> <!-- Your scrollable view goes here --> </me.dkzwm.widget.srl.SmoothRefreshLayout>
-
Initialize and configure the SmoothRefreshLayout in your Activity or Fragment:
val refreshLayout = findViewById<SmoothRefreshLayout>(R.id.refresh_layout) refreshLayout.setOnRefreshListener { // Perform refresh operation refreshLayout.refreshComplete() }
Competitor Comparisons
🔥下拉刷新、上拉加载、二级刷新、淘宝二楼、RefreshLayout、OverScroll,Android智能下拉刷新框架,支持越界回弹、越界拖动,具有极强的扩展性,集成了几十种炫酷的Header和 Footer。
Pros of SmartRefreshLayout
- More extensive customization options for header and footer styles
- Larger community and more frequent updates
- Better documentation and examples
Cons of SmartRefreshLayout
- Slightly more complex implementation due to additional features
- Larger library size, which may impact app size
Code Comparison
SmoothRefreshLayout:
SmoothRefreshLayout refreshLayout = findViewById(R.id.refresh_layout);
refreshLayout.setOnRefreshListener(new RefreshingListenerAdapter() {
@Override
public void onRefreshing() {
// Refresh logic here
}
});
SmartRefreshLayout:
RefreshLayout refreshLayout = findViewById(R.id.refreshLayout);
refreshLayout.setOnRefreshListener(new OnRefreshListener() {
@Override
public void onRefresh(RefreshLayout refreshlayout) {
// Refresh logic here
}
});
Both libraries offer similar basic functionality for implementing pull-to-refresh in Android applications. SmartRefreshLayout provides more built-in header and footer styles, making it easier to create visually appealing refresh animations. However, this comes at the cost of a slightly larger library size.
SmoothRefreshLayout offers a more lightweight solution with a simpler API, which may be preferable for projects with minimal customization needs. SmartRefreshLayout's larger community and more frequent updates can be beneficial for long-term support and feature additions.
In terms of implementation, both libraries have similar ease of use, with SmartRefreshLayout offering more options for customization out of the box.
Ultra Pull to Refresh for Android. Support all the views.
Pros of android-Ultra-Pull-To-Refresh
- Simpler implementation with fewer configuration options
- Lightweight and easy to integrate into existing projects
- Well-documented with clear examples and usage instructions
Cons of android-Ultra-Pull-To-Refresh
- Less customizable compared to SmoothRefreshLayout
- Limited support for advanced features like nested scrolling
- Not actively maintained (last update was several years ago)
Code Comparison
SmoothRefreshLayout:
mRefreshLayout = findViewById(R.id.smoothRefreshLayout);
mRefreshLayout.setOnRefreshListener(new RefreshingListenerAdapter() {
@Override
public void onRefreshing() {
// Refresh logic here
}
});
android-Ultra-Pull-To-Refresh:
mPtrFrame = (PtrFrameLayout) findViewById(R.id.store_house_ptr_frame);
mPtrFrame.setPtrHandler(new PtrHandler() {
@Override
public void onRefreshBegin(PtrFrameLayout frame) {
// Refresh logic here
}
});
Both libraries offer similar basic functionality for implementing pull-to-refresh in Android applications. SmoothRefreshLayout provides more advanced features and customization options, making it suitable for complex projects. android-Ultra-Pull-To-Refresh, on the other hand, offers a simpler implementation that may be preferable for smaller projects or quick prototypes. However, its lack of recent updates may be a concern for long-term maintainability.
Phoenix Pull-to-Refresh
Pros of Phoenix
- Visually appealing and customizable animations
- Easy to implement with minimal setup
- Lightweight library with a small footprint
Cons of Phoenix
- Limited to pull-to-refresh functionality only
- Less actively maintained compared to SmoothRefreshLayout
- Fewer configuration options and customization features
Code Comparison
Phoenix implementation:
val refreshLayout = PullToRefreshView(this)
refreshLayout.setOnRefreshListener {
// Refresh logic here
refreshLayout.setRefreshing(false)
}
SmoothRefreshLayout implementation:
val refreshLayout = SmoothRefreshLayout(this)
refreshLayout.setOnRefreshListener {
// Refresh logic here
refreshLayout.refreshComplete()
}
refreshLayout.autoRefresh()
Summary
Phoenix offers a visually appealing and easy-to-implement pull-to-refresh solution, while SmoothRefreshLayout provides more comprehensive refresh and load-more functionality with extensive customization options. SmoothRefreshLayout is more actively maintained and offers a wider range of features, making it suitable for complex implementations. Phoenix is ideal for projects requiring a simple, attractive pull-to-refresh mechanism with minimal setup.
DEPRECATED
Pros of Android-PullToRefresh
- Mature and well-established library with a large user base
- Supports multiple view types (ListView, GridView, WebView, etc.)
- Extensive documentation and examples available
Cons of Android-PullToRefresh
- No longer actively maintained (last commit in 2015)
- Limited customization options compared to newer libraries
- Lacks support for modern Android features and Material Design
Code Comparison
Android-PullToRefresh:
PullToRefreshListView mPullRefreshListView = (PullToRefreshListView) findViewById(R.id.pull_refresh_list);
mPullRefreshListView.setOnRefreshListener(new OnRefreshListener<ListView>() {
@Override
public void onRefresh(PullToRefreshBase<ListView> refreshView) {
// Do work to refresh the list here
}
});
SmoothRefreshLayout:
SmoothRefreshLayout mRefreshLayout = findViewById(R.id.refresh_layout);
mRefreshLayout.setOnRefreshListener(new RefreshingListenerAdapter() {
@Override
public void onRefreshing() {
// Do work to refresh the list here
}
});
SmoothRefreshLayout offers a more modern and flexible approach to implementing pull-to-refresh functionality. It supports a wider range of customization options and is actively maintained, making it a better choice for new projects. However, Android-PullToRefresh may still be suitable for legacy applications or those requiring support for older Android versions.
A reusable pull-to-refresh and pull-to-loadmore widget
Pros of SwipeToLoadLayout
- Simpler implementation with fewer customization options, making it easier to use for basic pull-to-refresh functionality
- Lightweight library with a smaller footprint
- Supports both pull-down-to-refresh and pull-up-to-load-more out of the box
Cons of SwipeToLoadLayout
- Less flexible and customizable compared to SmoothRefreshLayout
- Fewer animation options and visual styles available
- Limited support for advanced features like nested scrolling or multi-directional refreshing
Code Comparison
SmoothRefreshLayout:
mRefreshLayout = findViewById(R.id.smoothRefreshLayout);
mRefreshLayout.setOnRefreshListener(new RefreshingListenerAdapter() {
@Override
public void onRefreshing() {
// Refresh logic here
}
});
SwipeToLoadLayout:
swipeToLoadLayout = findViewById(R.id.swipeToLoadLayout);
swipeToLoadLayout.setOnRefreshListener(new OnRefreshListener() {
@Override
public void onRefresh() {
// Refresh logic here
}
});
Both libraries offer similar basic implementation, but SmoothRefreshLayout provides more advanced options for customization and configuration. SwipeToLoadLayout focuses on simplicity and ease of use for common pull-to-refresh scenarios.
A pull to refresh layout for android, the RecyclerRefreshLayout is based on the SwipeRefreshLayout. support all the views, highly customizable, code simplicity, etc. really a practical RefreshLayout!
Pros of RecyclerRefreshLayout
- Specifically designed for RecyclerView, providing optimized performance
- Lightweight and focused on a single purpose, potentially easier to integrate
- Supports both pull-down refresh and pull-up load more functionalities
Cons of RecyclerRefreshLayout
- Less flexible compared to SmoothRefreshLayout, which supports multiple view types
- May have fewer customization options for the refresh header and footer
- Limited to RecyclerView, while SmoothRefreshLayout can work with various scrollable views
Code Comparison
SmoothRefreshLayout:
SmoothRefreshLayout refreshLayout = findViewById(R.id.refresh_layout);
refreshLayout.setOnRefreshListener(new RefreshingListenerAdapter() {
@Override
public void onRefreshing() {
// Refresh logic here
}
});
RecyclerRefreshLayout:
RecyclerRefreshLayout refreshLayout = findViewById(R.id.refresh_layout);
refreshLayout.setOnRefreshListener(new OnRefreshListener() {
@Override
public void onRefresh() {
// Refresh logic here
}
});
Both libraries offer similar basic usage, but SmoothRefreshLayout provides more extensive customization options and supports various view types, while RecyclerRefreshLayout is tailored specifically for RecyclerView implementations.
Convert designs to code with AI
Introducing Visual Copilot: A new AI model to turn Figma designs to high quality code using your components.
Try Visual CopilotREADME
SmoothRefreshLayout
English | ä¸æ
ä¸ä¸ªé«æçAndroidå·æ°åºï¼ç论ä¸æ¯æææçè§å¾ï¼æ¯å®æ¹çSwipeRefreshLayoutæ´å¼ºå¤§ä¸ä½¿ç¨æ¹ä¾¿.
ç¹æ§:
- ç论ä¸æ¯æææçè§å¾,ä¸å¯æ ¹æ®å ·ä½éæ±é«æéé .
- æ¯æå¤ç¹è§¦æ¸.
- æ¯æåµå¥æ»å¨,å®æ´å®ç°äºNestedScrollingChild3ï¼NestedScrollingParent3 æ¥å£,ç©è½¬CoordinatorLayout.
- ç´æ¥ç»§æ¿èªViewGroup,æ¥æåè¶çæ§è½,æ¯æç±»FameLayoutçç¹æ§ï¼GravityãMargin).
- æ¯æèªå¨å·æ°ãèªå¨ä¸æå è½½ãå°åºèªå¨å è½½æ´å¤ï¼ä¸æ¨èï¼å»ºè®®ä½¿ç¨Adapterå®ç°ï¼å¯èªå®ä¹å°åºå¤æé»è¾åè°å®ç°é¢å è½½æ´å¤ï¼.
- æ¯æè¶çåå¼¹ï¼æ¯æåºäºç©çç¹æ§çè¶çåå¼¹ææ.
- æ¯æå·æ°è§å¾èªå®æ ·å¼:STYLE_DEFAULT(é»è®¤ä¸æ¹å大å°)ãSTYLE_SCALE(å¨ææ¹å大å°ï¼ä¼å¨SRLå é¨æµé并å¸å±ï¼æ以æ§è½ä¼ææ失)ãSTYLE_PIN(ä¸ä¼æ¹åè§å¾å¤§å°ï¼åºå®å¨é¡¶é¨æè åºé¨)ãSTYLE_FOLLOW_SCALE(å 纵åè·é移å¨å¹¶ä¸ä¸æ¹åè§å¾å¤§å°ï¼å¤§äºè§å¾é«åº¦åå¨ææ¹åè§å¾å¤§å°ä¸æ§è½ä¼ææ失)ãSTYLE_FOLLOW_PIN(ä¸ä¼æ¹åè§å¾å¤§å°ï¼å 纵åè·é移å¨ï¼å¤§äºè§å¾é«åº¦ååºå®)ãSTYLE_FOLLOW_CENTER(ä¸ä¼æ¹åè§å¾å¤§å°ï¼å 纵åè·é移å¨ï¼å¤§äºè§å¾é«åº¦å让è§å¾ä¿æå¨ç§»å¨çè·ç¦»ä¸å¿ç¹).
- æ¯æäºçº§å·æ°äºä»¶ï¼TwoLevelSmoothRefreshLayoutï¼,PS:æ·å®äºæ¥¼ã京ä¸æ´»å¨.
- æ¯æ横åå·æ°(HorizontalSmoothRefreshLayout).
- æ¯æListViewãGridViewãRecyclerViewå è½½æ´å¤çåæ¥å¹³æ»æ»å¨.
- æ¯ææå¿:åæ¥Fling(å·æ°è§å¾ä»å¯è§çæ åµä¸,ä¼å åæ»éèå·æ°è§å¾,èååä¸ä¼ éFlingæå¿).
- æ¯æä½ä¸ºå¯æ伸å é¨è§å¾å¸å±ä½¿ç¨ï¼ç±»å°ç±³è®¾ç½®é¡µææï¼.
- 丰å¯çåè°æ¥å£åè°è¯ä¿¡æ¯,å¯å©ç¨ç°æAPIå®ç°ä¸°å¯çææ.
å¼å ¥
æ·»å å¦ä¸ä¾èµå°ä½ ç build.gradle æ件:
dependencies {
implementation 'com.github.dkzwm:srl-core:1.7.2.4'
implementation 'com.github.dkzwm:srl-ext-classics:1.7.2.4'
implementation 'com.github.dkzwm:srl-ext-material:1.7.2.4'
implementation 'com.github.dkzwm:srl-ext-dynamic-rebound:1.7.2.4'
implementation 'com.github.dkzwm:srl-ext-horizontal:1.7.2.4'
implementation 'com.github.dkzwm:srl-ext-two-level:1.7.2.4'
implementation 'com.github.dkzwm:srl-ext-util:1.7.2.4'
}
æ¼ç¤ºç¨åº
ä¸è½½ Demo.apk
æ´æ°æ¥å¿
èçæ¬å级å¡å¿ æ¥ç
å¿«ç §
使ç¨
å¨Xmlä¸é ç½®
<?xml version="1.0" encoding="utf-8"?>
<me.dkzwm.widget.srl.SmoothRefreshLayout
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">
<TextView
android:layout_width="match_parent"
android:layout_height="match_parent"/>
</me.dkzwm.widget.srl.SmoothRefreshLayout>
Java代ç é ç½®
SmoothRefreshLayout refreshLayout = (SmoothRefreshLayout)findViewById(R.id.smoothRefreshLayout);
refreshLayout.setHeaderView(new ClassicHeader(this));
refreshLayout.setOnRefreshListener(new RefreshingListenerAdapter() {
@Override
public void onRefreshing() {
mHandler.postDelayed(new Runnable() {
@Override
public void run() {
refreshLayout.refreshComplete();
}
}, 4000);
}
});
èªå®ä¹å·æ°è§å¾
æ¥å£å®ä¹
public interface IRefreshView <T extends IIndicator> {
byte TYPE_HEADER = 0;
byte TYPE_FOOTER = 1;
byte STYLE_DEFAULT = 0;
byte STYLE_SCALE = 1;
byte STYLE_PIN = 2;
byte STYLE_FOLLOW_SCALE = 3;
byte STYLE_FOLLOW_PIN = 4;
byte STYLE_FOLLOW_CENTER = 5;
/**
* è¿åæ¯å¤´é¨è§å¾è¿æ¯å°¾é¨è§å¾;
*/
int getType();
/**
* ä¸è¬æ
åµé½æ¯Viewå®ç°æ¬æ¥å£ï¼æ以è¿åthis;
*/
View getView();
/**
* è·åè§å¾æ ·å¼ï¼èª1.4.8çæ¬åæ¯æ6ç§æ ·å¼ï¼STYLE_DEFAULTãSTYLE_SCALEãSTYLE_PINãSTYLE_FOLLOW_SCALEãSTYLE_FOLLOW_PINãSTYLE_FOLLOW_CENTER;
*/
int getStyle();
/**
* è·åè§å¾çèªå®ä¹é«åº¦ï¼å½è§å¾æ ·å¼ä¸ºSTYLE_SCALEåSTYLE_FOLLOW_SCALEæ¶ï¼å¿
é¡»è¿åä¸ä¸ªç¡®åä¸å¤§äº0çå¼ï¼ä½¿ç¨æ¨ªåå·æ°åºæ¶ï¼è¯¥å±æ§å®é
åºè¯¥è¿åçæ¯è§å¾ç宽度;
* èª1.6.1çæ¬å¼å§ï¼å¦ææ³è¦å½åè§å¾éºæ»¡å¸å±å³MATCH_PARENTï¼é£ä¹æ¯æè¿åViewGroup.LayoutParams.MATCH_PARENT对åºçå¼å³`-1`;
*/
int getCustomHeight();
/**
* ææ离å¼å±å¹;
*/
void onFingerUp(SmoothRefreshLayout layout, T indicator);
/**
* éç½®è§å¾;
*/
void onReset(SmoothRefreshLayout layout);
/**
* éæ°é
ç½®è§å¾ï¼åå¤å·æ°;
*/
void onRefreshPrepare(SmoothRefreshLayout layout);
/**
* å¼å§å·æ°;
*/
void onRefreshBegin(SmoothRefreshLayout layout, T indicator);
/**
* å·æ°å®æ;
*/
void onRefreshComplete(SmoothRefreshLayout layout,boolean isSuccessful);
/**
* å½å¤´é¨æè
å°¾é¨è§å¾åçä½ç½®åå;
*/
void onRefreshPositionChanged(SmoothRefreshLayout layout, byte status, T indicator);
/**
* å½å¤´é¨æè
å°¾é¨è§å¾ä»ç¶å¤äºå¤çäºå¡ä¸ï¼è¿æ¶å移å¨å
¶ä»å·æ°è§å¾åä¼è°ç¨è¯¥æ¹æ³;
* å¨1.4.6çæ¬æ°å å
¥;
*/
void onPureScrollPositionChanged(SmoothRefreshLayout layout, byte status, T indicator);
}
æ·»å èªå®ä¹å·æ°è§å¾
- å ¨å±éæ代ç æé
SmoothRefreshLayout.setDefaultCreator(new IRefreshViewCreator() {
@Override
public IRefreshView<IIndicator> createHeader(SmoothRefreshLayout layout) {
ClassicHeader header = new ClassicHeader(layout.getContext());
return header;
}
@Override
public IRefreshView<IIndicator> createFooter(SmoothRefreshLayout layout) {
ClassicFooter footer = new ClassicFooter(layout.getContext());
return footer;
}
});
- å¨æ代ç æ·»å
ClassicHeader header = new ClassicHeader(mRefreshLayout.getContext());
mRefreshLayout.setHeaderView(header);
ClassicFooter footer = new ClassicFooter(mRefreshLayout.getContext());
mRefreshLayout.setFooterView(footer);
- 请ç´æ¥åå ¥Xmlæ件,SmoothRefreshLayoutä¼æ ¹æ®æ·»å çViewæ¯å¦æ¯å®ç°äºIRefreshViewæ¥å£è¿è¡å¤æ
å®ç°ç±»QQä¸æé»å°¼ææ
mRefreshLayout.setIndicatorOffsetCalculator(new IIndicator.IOffsetCalculator() {
@Override
public float calculate(@IIndicator.MovingStatus int status, int currentPos, float offset) {
if (status == IIndicator.MOVING_HEADER) {
if (offset < 0) {
//å¦æå¸ææå¨ç¼©åæ¶ç±»ä¼¼QQä¸æ ·æ²¡æé»å°¼ææï¼é»å°¼ææåªåå¨äºä¸æåå¯ä»¥å¨æ¤è¿åoffset
//å¦æå¸ææå¨ç¼©åæ¶ç±»ä¼¼QQä¸æ ·æé»å°¼ææï¼é£ä¹è¯·æ³¨éæè¿ä¸ªå¤æè¯å¥
return offset;
}
return (float) Math.pow(Math.pow(currentPos / 2, 1.28d) + offset, 1 / 1.28d) * 2 - currentPos;
} else if (status == IIndicator.MOVING_FOOTER) {
if (offset > 0) {
//å¦æå¸ææå¨ç¼©åæ¶ç±»ä¼¼QQä¸æ ·æ²¡æé»å°¼ææï¼é»å°¼ææåªåå¨äºä¸æåå¯ä»¥å¨æ¤è¿åoffset
//å¦æå¸ææå¨ç¼©åæ¶ç±»ä¼¼QQä¸æ ·æé»å°¼ææï¼é£ä¹è¯·æ³¨éæè¿ä¸ªå¤æè¯å¥
return offset;
}
return -((float) Math.pow(Math.pow(currentPos / 2, 1.28d) - offset, 1 / 1.28d) * 2 - currentPos);
} else {
if (offset > 0) {
return (float) Math.pow(offset, 1 / 1.28d) * 2;
} else if (offset < 0) {
return -(float) Math.pow(-offset, 1 / 1.28d) * 2;
} else {
return offset;
}
}
}
});
Xmlå±æ§
SmoothRefreshLayout èªèº«é ç½®
å称 | ç±»å | æè¿° |
---|---|---|
sr_content | reference | æå®å 容è§å¾çèµæºID |
sr_resistance | float | 移å¨å·æ°è§å¾æ¶åç移å¨é»å°¼ï¼é»è®¤:1.65f ï¼ |
sr_resistanceOfFooter | float | 移å¨Footerè§å¾æ¶åç移å¨é»å°¼ï¼é»è®¤:1.65f ï¼ |
sr_resistanceOfHeader | float | 移å¨Headerè§å¾æ¶åç移å¨é»å°¼ï¼é»è®¤:1.65f ï¼ |
sr_ratioToRefresh | float | 触åå·æ°æ¶ä½ç½®å å·æ°è§å¾çé«åº¦æ¯ï¼é»è®¤:1f ï¼ |
sr_ratioOfHeaderToRefresh | float | 触åå·æ°æ¶ä½ç½®å Headerè§å¾çé«åº¦æ¯ï¼é»è®¤:1f ï¼ |
sr_ratioOfFooterToRefresh | float | 触åå è½½æ´å¤æ¶ä½ç½®å Footerè§å¾çé«åº¦æ¯ï¼é»è®¤:1f ï¼ |
sr_ratioToKeep | float | å·æ°ä¸ä¿æè§å¾ä½ç½®å å·æ°è§å¾çé«åº¦æ¯ï¼é»è®¤:1f ï¼,该å±æ§çå¼å¿
é¡»å°äºçäºè§¦åå·æ°é«åº¦æ¯æä¼æææ |
sr_ratioToKeepHeader | float | å·æ°ä¸ä¿æè§å¾ä½ç½®å Headerè§å¾çé«åº¦æ¯ï¼é»è®¤:1f ï¼,该å±æ§çå¼å¿
é¡»å°äºçäºè§¦åå·æ°é«åº¦æ¯æä¼æææ |
sr_ratioToKeepFooter | float | å·æ°ä¸ä¿æè§å¾ä½ç½®å Footerè§å¾çé«åº¦æ¯ï¼é»è®¤:1f ï¼,该å±æ§çå¼å¿
é¡»å°äºçäºè§¦åå·æ°é«åº¦æ¯æä¼æææ |
sr_maxMoveRatio | float | æ大移å¨è·ç¦»å å·æ°è§å¾çé«åº¦æ¯ï¼é»è®¤:0f ï¼è¡¨ç¤ºä¸ä¼è§¦åï¼ |
sr_maxMoveRatioOfHeader | float | æ大移å¨è·ç¦»å Headerè§å¾çé«åº¦æ¯ï¼é»è®¤:0f ï¼è¡¨ç¤ºä¸ä¼è§¦åï¼ |
sr_maxMoveRatioOfFooter | float | æ大移å¨è·ç¦»å Footerè§å¾çé«åº¦æ¯ï¼é»è®¤:0f ï¼è¡¨ç¤ºä¸ä¼è§¦åï¼ |
sr_closeDuration | integer | æå®æ¶ç¼©å·æ°è§å¾å°èµ·å§ä½ç½®çæ¶é¿ï¼é»è®¤:350 ï¼ |
sr_closeHeaderDuration | integer | æå®æ¶ç¼©Headerè§å¾å°èµ·å§ä½ç½®çæ¶é¿ï¼é»è®¤:350 ï¼ |
sr_closeFooterDuration | integer | æå®æ¶ç¼©Footerè§å¾å°èµ·å§ä½ç½®çæ¶é¿ï¼é»è®¤:350 ï¼ |
sr_backToKeepDuration | integer | 设置åæ»å°ä¿æå·æ°è§å¾ä½ç½®çæ¶é´ï¼é»è®¤:200 ï¼ |
sr_backToKeepHeaderDuration | integer | 设置åæ»å°ä¿æHeaderè§å¾ä½ç½®çæ¶é´ï¼é»è®¤:200 ï¼ |
sr_backToKeepFooterDuration | integer | 设置åæ»å°ä¿æFooterè§å¾ä½ç½®çæ¶é´ï¼é»è®¤:200 ï¼ |
sr_enablePinContent | boolean | åºå®å
容è§å¾ï¼é»è®¤:false ï¼ |
sr_enableKeep | boolean | å·æ°ä¸ä¿æè§å¾åçå¨æ设置çåºè¯¥åççä½ç½®ï¼é»è®¤:true ï¼ |
sr_enablePullToRefresh | boolean | æå¨å·æ°,ä¸ææè
ä¸æå°è§¦åå·æ°ä½ç½®å³ç«å³è§¦åå·æ°ï¼é»è®¤:false ï¼ |
sr_enableOverScroll | boolean | è¶çåå¼¹ï¼é»è®¤:true ï¼ |
sr_enableRefresh | boolean | 设置æ¯å¦å¯ç¨ä¸æå·æ°ï¼é»è®¤:ture ï¼ |
sr_enableLoadMore | boolean | 设置æ¯å¦å¯ç¨å è½½æ´å¤ï¼é»è®¤:false ï¼ |
sr_mode | enum | 模å¼è®¾ç½®ï¼é»è®¤:MODE_DEFAULT 为å·æ°æ§ä»¶æ¨¡å¼ï¼ |
sr_stickyHeader | reference | æå®é»è´´å¤´é¨çèµæºID |
sr_stickyFooter | reference | æå®é»è´´å°¾é¨çèµæºID |
TwoLevelSmoothRefreshLayout èªèº«é ç½®
å称 | ç±»å | æè¿° |
---|---|---|
sr_enableTwoLevelRefresh | boolean | 设置æ¯å¦å¯ç¨äºçº§å·æ°ï¼é»è®¤:true ï¼ |
sr_backToKeep2Duration | boolean | 设置åæ»å°ä¿æäºçº§å·æ°å¤´é¨å¤äºäºçº§å·æ°è¿ç¨ä¸çæ¶é¿ï¼é»è®¤:500 ï¼ |
sr_closeHeader2Duration | boolean | 设置å
³éäºçº§å·æ°å¤´é¨çæ¶é¿ï¼é»è®¤:500 ï¼ |
SmoothRefreshLayoutå 裹å é¨å ¶ä»Viewæ¯æé ç½®
å称 | ç±»å | æè¿° |
---|---|---|
layout_gravity | flag | æå®å ¶å®è¢«å 裹è§å¾ç对é½å±æ§(é targetViewãérefreshView) |
SmoothRefreshLayout javaå±æ§è®¾ç½®æ¹æ³
å称 | åæ° | æè¿° |
---|---|---|
setHeaderView | IRefreshView | é 置头é¨è§å¾ |
setFooterView | IRefreshView | é 置尾é¨è§å¾ |
setContentView | View | é ç½®å 容è§å¾ |
setMode | int | é ç½®å½åæ¨¡å¼ |
setLayoutManager | LayoutManager | é ç½®èªå®ä¹å¸å±ç®¡çå¨ |
setDisableWhenAnotherDirectionMove | boolean | å
é¨è§å¾å«æå
¶ä»æ¹åæ»å¨è§å¾æ¶é设置该å±æ§ä¸ºtureï¼é»è®¤:false ï¼ |
setMaxOverScrollDuration | int | 设置è¶çåå¼¹å¨ç»æé¿æ¶é´ï¼é»è®¤:350 ï¼ |
setMinOverScrollDuration | int | 设置è¶çåå¼¹å¨ç»æçæ¶é´ï¼é»è®¤:100 ï¼ |
setResistance | float | 移å¨å·æ°è§å¾æ¶åç移å¨é»å°¼ï¼é»è®¤:1.65f ï¼ |
setResistanceOfFooter | float | 移å¨Footerè§å¾æ¶åç移å¨é»å°¼ï¼é»è®¤:1.65f ï¼ |
setResistanceOfHeader | float | 移å¨Headerè§å¾æ¶åç移å¨é»å°¼ï¼é»è®¤:1.65f ï¼ |
setRatioToRefresh | float | 触åå·æ°æ¶ä½ç½®å å·æ°è§å¾çé«åº¦æ¯ï¼é»è®¤:1.1f ï¼ |
setRatioOfHeaderToRefresh | float | 触åå·æ°æ¶ä½ç½®å Headerè§å¾çé«åº¦æ¯ï¼é»è®¤:1.1f ï¼ |
setRatioOfFooterToRefresh | float | 触åå è½½æ´å¤æ¶ä½ç½®å Footerè§å¾çé«åº¦æ¯ï¼é»è®¤:1.1f ï¼ |
setRatioToKeep | float | å·æ°ä¸ä¿æè§å¾ä½ç½®å å·æ°è§å¾çé«åº¦æ¯ï¼é»è®¤:1f ï¼,该å±æ§çå¼å¿
é¡»å°äºçäºè§¦åå·æ°é«åº¦æ¯æä¼æææ |
setRatioToKeepHeader | float | å·æ°ä¸ä¿æè§å¾ä½ç½®å Headerè§å¾çé«åº¦æ¯ï¼é»è®¤:1f ï¼,该å±æ§çå¼å¿
é¡»å°äºçäºè§¦åå·æ°é«åº¦æ¯æä¼æææ |
setRatioToKeepFooter | float | å·æ°ä¸ä¿æè§å¾ä½ç½®å Footerè§å¾çé«åº¦æ¯ï¼é»è®¤:1f ï¼,该å±æ§çå¼å¿
é¡»å°äºçäºè§¦åå·æ°é«åº¦æ¯æä¼æææ |
setMaxMoveRatio | float | æ大移å¨è·ç¦»å å·æ°è§å¾çé«åº¦æ¯ï¼é»è®¤:0f ï¼è¡¨ç¤ºä¸ä¼è§¦åï¼ |
setMaxMoveRatioOfHeader | float | æ大移å¨è·ç¦»å Headerè§å¾çé«åº¦æ¯ï¼é»è®¤:0f ï¼è¡¨ç¤ºä¸ä¼è§¦åï¼ |
setMaxMoveRatioOfFooter | float | æ大移å¨è·ç¦»å Footerè§å¾çé«åº¦æ¯ï¼é»è®¤:0f ï¼è¡¨ç¤ºä¸ä¼è§¦åï¼ |
setDurationToClose | int | æå®æ¶ç¼©å·æ°è§å¾å°èµ·å§ä½ç½®çæ¶é¿ï¼é»è®¤:350 ï¼ |
setDurationToCloseHeader | int | æå®æ¶ç¼©Headerè§å¾å°èµ·å§ä½ç½®çæ¶é¿ï¼é»è®¤:350 ï¼ |
setDurationToCloseFooter | int | æå®æ¶ç¼©Footerè§å¾å°èµ·å§ä½ç½®çæ¶é¿ï¼é»è®¤:350 ï¼ |
setDurationOfBackToKeep | integer | 设置åæ»å°ä¿æå·æ°è§å¾ä½ç½®çæ¶é´ï¼é»è®¤:200 ï¼ |
setDurationOfBackToKeepHeader | integer | 设置åæ»å°ä¿æHeaderè§å¾ä½ç½®çæ¶é´ï¼é»è®¤:200 ï¼ |
setDurationOfBackToKeepFooter | integer | 设置åæ»å°ä¿æFooterè§å¾ä½ç½®çæ¶é´ï¼é»è®¤:200 ï¼ |
setEnablePinContentView | boolean | åºå®å
容è§å¾ï¼é»è®¤:false ï¼ |
setEnablePullToRefresh | boolean | æå¨å·æ°,ä¸ææè
ä¸æå°è§¦åå·æ°ä½ç½®å³ç«å³è§¦åå·æ°ï¼é»è®¤:false ï¼ |
setEnableOverScroll | boolean | è¶çåå¼¹ï¼é»è®¤:true ï¼ |
setEnableInterceptEventWhileLoading | boolean | å·æ°ä¸æ¦æªä¸ååºè§¦æ¸æä½ï¼é»è®¤:false ï¼ |
setEnableHeaderDrawerStyle | boolean | Headeræ½å±æ ·å¼,å³Headerè§å¾å¨å
容è§å¾ä¸é¢ï¼é»è®¤:false ï¼ |
setEnableFooterDrawerStyle | boolean | Footeræ½å±æ ·å¼,å³Footerè§å¾å¨å
容è§å¾ä¸é¢ï¼é»è®¤:false ï¼ |
setDisablePerformRefresh | boolean | å
³é触åHeaderå·æ°ï¼é»è®¤:false ï¼ |
setDisablePerformLoadMore | boolean | å
³é触åFooterå·æ°ï¼é»è®¤:false ï¼ |
setEnableNoMoreData | boolean | 设置Footer没ææ´å¤æ°æ®ï¼è¯¥é项设置true æ¶å¨Frameå±çåsetDisablePerformLoadMore 设置为true ï¼åªæ¯èªå®ä¹è§å¾å¯ä»¥æ ¹æ®è¯¥æ å¿ä½æ¹åè§å¾æ ·å¼,ClassicFooter é»è®¤å®ç°äºå¯¹è¯¥å±æ§çæ¯æï¼é»è®¤:false ï¼ |
setEnableNoMoreDataAndNoSpringBack | boolean | 设置Footer没ææ´å¤æ°æ®ä¸ä¸ååå¼¹ |
setDisableRefresh | boolean | ç¦ç¨Headerå·æ°ï¼é»è®¤:false ï¼ |
setDisableLoadMore | boolean | ç¦ç¨Footerå·æ°ï¼é»è®¤:false ï¼ |
setEnableKeepRefreshView | boolean | å·æ°ä¸ä¿æè§å¾åçå¨æ设置çåºè¯¥åççä½ç½®ï¼é»è®¤:true ï¼ |
setEnableAutoRefresh | boolean | å°é¡¶é¨èªå¨å·æ°ï¼é»è®¤:false ï¼ |
setEnableAutoLoadMore | boolean | å°åºé¨èªå¨å è½½ï¼é»è®¤:false ï¼ |
setEnablePinRefreshViewWhileLoading | boolean | åºå®å·æ°è§å¾å¨æ设置çåºè¯¥åççä½ç½®ï¼å¹¶ä¸ä¸ååºç§»å¨ï¼å³Materialæ ·å¼ï¼é»è®¤:false ï¼,设置å¼å¯ä¼åæ¶å¼å¯setEnablePinContentView åsetEnableKeepRefreshView 2个é项 |
setSpringInterpolator | Interpolator | 设置主å¨å¼¹åºæ¶çæ»å¨æå¼å¨ |
setSpringBackInterpolator | Interpolator | 设置éæ¾æ¶çæ»å¨æå¼å¨ |
setEnableCompatSyncScroll | boolean | 设置æ¯å¦å¼å¯åæ»æ¶çåæ¥æ»å¨ï¼é»è®¤:true ï¼ |
setDisableLoadMoreWhenContentNotFull | boolean | 设置å½å 容è§å¾æªæ»¡å±æ¶å ³éå è½½æ´å¤ |
setStickyHeaderResId | int | 设置é»è´´å¤´é¨è§å¾çèµæºID |
setStickyFooterResId | int | 设置é»è´´å¤´é¨è§å¾çèµæºID |
setEnableOldTouchHandling | boolean | 设置å¯ç¨èçæ¬ç触æ¸äºä»¶å¤çé»è¾ |
setScrollTargetView | View | 设置å¤ææ¯å¦æ»å°å°è¾¹ç对åºçè§å¾,ä¾å¦å¨SmoothRefreshLayoutä¸æä¸ä¸ªCoordinatorLayout,CoordinatorLayoutä¸æAppbarLayoutãRecyclerViewçï¼å è½½æ´å¤æ¶å¸æ被移å¨çè§å¾ä¸ºRecyclerViewèä¸æ¯CoordinatorLayout,é£ä¹è®¾ç½®RecyclerView为TargetViewå³å¯ |
SmoothRefreshLayout åè°
å称 | åæ° | æè¿° |
---|---|---|
setOnRefreshListener | T extends OnRefreshListener | 设置å·æ°äºä»¶çå¬åè° |
addLifecycleObserver | ILifecycleObserver | æ·»å çå½å¨æçå¬ |
addOnStatusChangedListener | addOnStatusChangedListener | 设置å é¨ç¶ææ¹ååè° |
addOnUIPositionChangedListener | OnUIPositionChangedListener | æ·»å è§å¾ä½ç½®ååççå¬åè° |
setOnSyncScrollCallback | OnSyncScrollCallback | 设置å®æå·æ°åè¿è¡å¹³æ»æ»å¨çåè° |
setOnPerformAutoLoadMoreCallBack | OnPerformAutoLoadMoreCallBack | 设置触åèªå¨å è½½æ´å¤çæ¡ä»¶åè°ï¼å¦æåè°çcanAutoLoadMore() æ¹æ³è¿åtrue åä¼ç«å³è§¦åå è½½æ´å¤ |
setOnPerformAutoRefreshCallBack | OnPerformAutoRefreshCallBack | 设置触åèªå¨å·æ°çæ¡ä»¶åè°ï¼å¦æåè°çcanAutoRefresh() æ¹æ³è¿åtrue åä¼ç«å³è§¦åå·æ° |
setOnHeaderEdgeDetectCallBack | OnHeaderEdgeDetectCallBack | 设置æ£æ¥å
容è§å¾æ¯å¦å¨é¡¶é¨çéè½½åè°ï¼SmoothRefreshLayoutå
é¨isNotYetInEdgeCannotMoveHeader() æ¹æ³ï¼ |
setOnFooterEdgeDetectCallBack | OnFooterEdgeDetectCallBack | 设置æ£æ¥å
容è§å¾æ¯å¦å¨åºé¨çéè½½åè°ï¼SmoothRefreshLayoutå
é¨isNotYetInEdgeCannotMoveFooter() æ¹æ³ï¼ |
setOnHookHeaderRefreshCompleteCallback | OnHookUIRefreshCompleteCallBack | 设置Headerå·æ°å®æçHookåè°ï¼å¯å®ç°å»¶è¿å®æå·æ° |
setOnHookFooterRefreshCompleteCallback | OnHookUIRefreshCompleteCallBack | 设置Footerå·æ°å®æçHookåè°ï¼å¯å®ç°å»¶è¿å®æå·æ° |
SmoothRefreshLayout å ¶å®
å称 | åæ° | æè¿° |
---|---|---|
setDefaultCreatorï¼éææ¹æ³ï¼ | IRefreshViewCreator | 设置å·æ°è§å¾å建è ,å¦æ没æç¹æ®æå®å·æ°è§å¾ä¸è®¾ç½®ç模å¼éè¦å·æ°è§å¾åä¼è°ç¨å建è æ建å·æ°è§å¾ |
refreshComplete | æ å | å·æ°å®æ,ä¸è®¾ç½®æåä¸æ¬¡å·æ°ç¶æ为æå |
refreshComplete | boolean | å·æ°å®æ,åæ°:设置æåä¸æ¬¡å·æ°æ¯å¦å·æ°æå |
refreshComplete | boolean,long | å·æ°å®æ,åæ°1:设置æåä¸æ¬¡å·æ°æ¯å¦å·æ°æå,åæ°2:设置延è¿éç½®å·æ°ç¶æçæ¶é´ï¼ä¼å 触åå·æ°è§å¾çå·æ°å®æåè°ï¼ä½å¨å»¶è¿çæ¶é´å åºå®é ä¸ç¶æä»æ¯å·æ°ç¶æï¼ |
refreshComplete | long | å·æ°å®æ,ä¸è®¾ç½®æåä¸æ¬¡å·æ°ç¶æ为æå,åæ°:设置延è¿éç½®å·æ°ç¶æçæ¶é´ï¼ä¼å 触åå·æ°è§å¾çå·æ°å®æåè°ï¼ä½å¨å»¶è¿çæ¶é´å åºå®é ä¸ç¶æä»æ¯å·æ°ç¶æï¼ |
setLoadingMinTime | long | 设置å¼å§å·æ°å°ç»æå·æ°çæå°æ¶é´å·®(é»è®¤:500 ),åæ°:æ¶é´å·® |
autoRefresh | æ å | èªå¨è§¦åHeaderå·æ°,ç«å³è§¦åå·æ°äºä»¶å¹¶æ»å¨å°è§¦åHeaderå·æ°ä½ç½® |
autoRefresh | boolean | èªå¨è§¦åHeaderå·æ°,åæ°:æ¯å¦ç«å³è§¦åå·æ°äºä»¶,ä¼æ»å¨å°è§¦åHeaderå·æ°ä½ç½® |
autoRefresh | boolean,boolean | èªå¨è§¦åHeaderå·æ°,åæ°1:æ¯å¦ç«å³è§¦åå·æ°äºä»¶,åæ°2:æ¯å¦æ»å¨å°è§¦åHeaderå·æ°ä½ç½® |
forceRefresh | æ å | 强å¶è§¦åFooterå·æ°ï¼è¯¥æ¹æ³ä¸ä¼è§¦åæ»å¨ |
autoLoadMore | æ å | èªå¨è§¦åFooterå·æ°,ç«å³è§¦åå·æ°äºä»¶å¹¶æ»å¨å°è§¦åFooterå·æ°ä½ç½® |
autoLoadMore | boolean | èªå¨è§¦åFooterå·æ°,åæ°:æ¯å¦ç«å³è§¦åå·æ°äºä»¶,ä¼æ»å¨å°è§¦åFooterå·æ°ä½ç½® |
autoLoadMore | boolean,boolean | èªå¨è§¦åFooterå·æ°,åæ°1:æ¯å¦ç«å³è§¦åå·æ°äºä»¶,åæ°2:æ¯å¦æ»å¨å°è§¦åFooterå·æ°ä½ç½® |
forceLoadMore | æ å | 强å¶è§¦åFooterå·æ°ï¼è¯¥æ¹æ³ä¸ä¼è§¦åæ»å¨ |
TwoLevelSmoothRefreshLayout javaå±æ§è®¾ç½®æ¹æ³
å称 | åæ° | æè¿° |
---|---|---|
setRatioOfHeaderToHintTwoLevel | float | 设置触åäºçº§å·æ°æ示æ¶çä½ç½®å Headerè§å¾çé«åº¦æ¯ |
setRatioOfHeaderToTwoLevel | float | 设置触åäºçº§å·æ°æ¶çä½ç½®å Headerè§å¾çé«åº¦æ¯ |
setRatioToKeepTwoLevelHeader | float | äºçº§å·æ°ä¸ä¿æè§å¾ä½ç½®å Headerè§å¾çé«åº¦æ¯ï¼é»è®¤:1f ï¼ |
setDisableTwoLevelRefresh | boolean | 设置æ¯å¦å
³éäºçº§å·æ°ï¼é»è®¤:false ï¼ |
setDurationOfBackToKeepTwoLevel | int | 设置åæ»å°ä¿æäºçº§å·æ°Headerè§å¾ä½ç½®çæ¶é´ï¼é»è®¤:500 ï¼ |
setDurationToCloseTwoLevel | int | 设置äºçº§å·æ°Headerå·æ°å®æåæ»å°èµ·å§ä½ç½®çæ¶é´ï¼é»è®¤:500 ï¼ |
TwoLevelSmoothRefreshLayout å ¶å®
å称 | åæ° | æè¿° |
---|---|---|
autoTwoLevelRefreshHint | æ å | èªå¨è§¦åäºçº§å·æ°æ示并æ»å¨å°è§¦åæ示ä½ç½®ååæ»åèµ·å§ä½ç½® |
autoTwoLevelRefreshHint | int | èªå¨è§¦åäºçº§å·æ°æ示并æ»å¨å°è§¦åæ示ä½ç½®ååçæå®æ¶é¿ï¼åæ°:åçå¤é¿æ¶é´ |
autoTwoLevelRefreshHint | boolean | èªå¨è§¦åäºçº§å·æ°æ示æ¯å¦æ»å¨å°è§¦åæ示ä½ç½®ååæ»åèµ·å§ä½ç½®ï¼åæ°:æ¯å¦æ»å°å°è§¦åä½ç½® |
autoTwoLevelRefreshHint | boolean,int | èªå¨è§¦åäºçº§å·æ°æ示,åæ°1:æ¯å¦æ»å¨å°è§¦åä½ç½®ï¼åæ°2:åçå¤é¿æ¶é´ |
autoTwoLevelRefreshHint | boolean,int,boolean | èªå¨è§¦åäºçº§å·æ°æ示,åæ°1:æ¯å¦æ»å¨å°è§¦åä½ç½®ï¼åæ°2:åçå¤é¿æ¶é´ï¼åæ°3:æ¯å¦å¯ä»¥è¢«è§¦æ¸ææï¼å³è§¦åæ示å¨ä½è¿ç¨ä¸æ¦æªè§¦æ¸äºä»¶ï¼ç´å°åæ»å°èµ·å§ä½ç½®å¹¶é置为é»è®¤ç¶æ |
Thanks
License
MIT License
Copyright (c) 2017 dkzwm
Copyright (c) 2015 liaohuqiu.net
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
Top Related Projects
🔥下拉刷新、上拉加载、二级刷新、淘宝二楼、RefreshLayout、OverScroll,Android智能下拉刷新框架,支持越界回弹、越界拖动,具有极强的扩展性,集成了几十种炫酷的Header和 Footer。
Ultra Pull to Refresh for Android. Support all the views.
Phoenix Pull-to-Refresh
DEPRECATED
A reusable pull-to-refresh and pull-to-loadmore widget
A pull to refresh layout for android, the RecyclerRefreshLayout is based on the SwipeRefreshLayout. support all the views, highly customizable, code simplicity, etc. really a practical RefreshLayout!
Convert designs to code with AI
Introducing Visual Copilot: A new AI model to turn Figma designs to high quality code using your components.
Try Visual Copilot