SwipeRefreshLayout停止刷新没有动画
问题描述:
我知道,调用myRefreshLayout.setRefreshing(false)将结束刷新动画...但它不仅停止,它完成它的当前旋转和动画离屏。SwipeRefreshLayout停止刷新没有动画
有没有办法避免在某些情况下?我期待着它立即消失。
谢谢!
答
尝试了这一点:
int cnt = swiperefresh.getChildCount();
for(int i=0; i<cnt; i++) {
View ch = swiperefresh.getChildAt(i);
if(ch.getClass().getSimpleName().equals("CircleImageView")) {
ch.clearAnimation();
ch.setVisibility(View.GONE);
swiperefresh.setRefreshing(false);
ch.clearAnimation();
break;
}
}
答
我找到了一种优雅的方式。在SwipeRefreshLayout
中有一个reset()
方法,它取消了动画,并立即隐藏了可绘制的进度而没有动画。不幸的是,这种方法是私有的。但它被称为setEnabled(false)
,所以你可以这样使用它:
swipeRefreshLayout.setEnabled(false)
swipeRefreshLayout.setEnabled(true)