码迷,mamicode.com
首页 > 其他好文 > 详细

SupportV7包中 SwipeRefreshLayout 修改下拉控件的距离

时间:2015-08-03 18:34:33      阅读:159      评论:0      收藏:0      [点我收藏+]

标签:

 1  //修改下拉距离
 2         ViewTreeObserver vto = mCategoryResults.mSwipeRefreshLayout.getViewTreeObserver();
 3         vto.addOnGlobalLayoutListener(new ViewTreeObserver.OnGlobalLayoutListener() {
 4             public void onGlobalLayout() {
 5 
 6                 final DisplayMetrics metrics = getResources().getDisplayMetrics();
 7                 Float mDistanceToTriggerSync = Math.min(((View) mCategoryResults.mSwipeRefreshLayout.getParent()).getHeight() * 0.6f, 500 * metrics.density);
 8 
 9                 try {
10                     Field field = SwipeRefreshLayout.class.getDeclaredField("mDistanceToTriggerSync");
11                     field.setAccessible(true);
12                     field.setFloat(mCategoryResults.mSwipeRefreshLayout, mDistanceToTriggerSync);
13                 } catch (Exception e) {
14                     e.printStackTrace();
15                 }
16                 ViewTreeObserver obs = mCategoryResults.mSwipeRefreshLayout.getViewTreeObserver();
17                 obs.removeOnGlobalLayoutListener(this);
18             }
19         });

 

SupportV7包中 SwipeRefreshLayout 修改下拉控件的距离

标签:

原文地址:http://www.cnblogs.com/dennisac/p/4699978.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!