Jon*_*put 11 android android-layout swiperefreshlayout
可能吗 ??正如标题所说
向下滑动以刷新布局,但坚持布局不要沿着滑动gusture向下移动
谢谢 - 我正在使用SwipeRefreshLayout
Cab*_*zas 23
你试试这种方式
listView.setOnScrollListener(new OnScrollListener() {
@Override
public void onScrollStateChanged(AbsListView view, int scrollState) {
}
@Override
public void onScroll(AbsListView view, int firstVisibleItem,
int visibleItemCount, int totalItemCount) {
boolean enable = false;
if(listView != null && listView.getChildCount() > 0){
// check if the first item of the list is visible
boolean firstItemVisible = listView.getFirstVisiblePosition() == 0;
// check if the top of the first item is visible
boolean topOfFirstItemVisible = listView.getChildAt(0).getTop() == 0;
// enabling or disabling the refresh layout
enable = firstItemVisible && topOfFirstItemVisible;
}
swipeRefreshLayout.setEnabled(enable);
}});
Run Code Online (Sandbox Code Playgroud)
如果listView具有paddingTop,则此代码不起作用
Jon*_*put 12
在我的反复试验之后,我找到了一个解决方案
http://www.dailydevbook.de/android-swiperefreshlayout-without-overscroll/
对于可以实现SwipeRefreshLayout的人来说,为了实现它
第1 步:从github 下载 android-support v4(开源)
第2 步:将java类复制到项目src中
note1-(重构SwipeRefreshLayout到mySwipeRefreshLayout以防止与原文混淆)note2-(修复这些类并使用彼此的源代替v4)
第3 步:更新代码使用
第4 步:更新布局使用
步骤5:在mySwipeRefreshLayout.java中,找到并更改为以下代码
private void updateContentOffsetTop ( int targetTop) {
final int currentTop = mTarget.getTop ();
if (targetTop> mDistanceToTriggerSync) {
targetTop = ( int ) mDistanceToTriggerSync;
} else if (targetTop < 0 ) {
targetTop = 0 ;
}
// SetTargetOffsetTopAndBottom (targetTop - currentTop);
setTargetOffsetTopAndBottom ( 0 ); // MOD: Prevent Scroll Down Animation
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
34573 次 |
| 最近记录: |