//修改下拉距离
ViewTreeObserver vto = mCategoryResults.mSwipeRefreshLayout.getViewTreeObserver();
vto.addOnGlobalLayoutListener(new ViewTreeObserver.OnGlobalLayoutListener() {
public void onGlobalLayout() { final DisplayMetrics metrics = getResources().getDisplayMetrics();
Float mDistanceToTriggerSync = Math.min(((View) mCategoryResults.mSwipeRefreshLayout.getParent()).getHeight() * 0.6f, 500 * metrics.density); try {
Field field = SwipeRefreshLayout.class.getDeclaredField("mDistanceToTriggerSync");
field.setAccessible(true);
field.setFloat(mCategoryResults.mSwipeRefreshLayout, mDistanceToTriggerSync);
} catch (Exception e) {
e.printStackTrace();
}
ViewTreeObserver obs = mCategoryResults.mSwipeRefreshLayout.getViewTreeObserver();
obs.removeOnGlobalLayoutListener(this);
}
});
05-11 00:09