今天开始使用谷歌的SwipeRefreshLayout,会记下一些坑
1.手动调用setRefreshing(true)不会出现刷新动画
原因是:SwipeRefreshLayout indicator does not appear when the setRefreshing(true)
is called before the SwipeRefreshLayout.onMeasure()
解决方法是:http://stackoverflow.com/questions/26858692/swiperefreshlayout-setrefreshing-not-showing-indicator-initially
mSwipeRefreshLayout.setProgressViewOffset(false, 0, (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 24, getResources().getDisplayMetrics())); mSwipeRefreshLayout.setRefreshing(true);
或者
mSwipeRefreshLayout.ponst(new Runnable(){ public void run(){ mSwipeRefreshLayout.setRefreshing(true); } });
个人推荐第二种方法,第一种方法有时候会出现bug