2016-04-14 104 views
1

我知道,調用myRefreshLayout.setRefreshing(false)將結束刷新動畫...但它不僅停止,它完成它的當前旋轉和動畫離屏。SwipeRefreshLayout停止刷新沒有動畫

有沒有辦法避免在某些情況下?我期待着它立即消失。

謝謝!

回答

0

嘗試了這一點:

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; 
           } 
          } 
0

我找到了一種優雅的方式。在SwipeRefreshLayout中有一個reset()方法,它取消了動畫,並立即隱藏了可繪製的進度而沒有動畫。不幸的是,這種方法是私有的。但它被稱爲setEnabled(false),所以你可以這樣使用它:

swipeRefreshLayout.setEnabled(false) 
swipeRefreshLayout.setEnabled(true)