SwipeRefreshLayout进入界面后自动显示刷新效果

这段时间用来SwipeRefreshLayout,代码优化的时候发现需要一进入界面就开启刷新效果,开始以为使用如下方式可以达到效果:


SwipeRefreshLayout.setRefersh(true);

new Handler().postDelay(new Runable{

        public void run(){

           //这里进行数据的加载

            SwipeRefreshLayout.setRefersh(false);

  ]

},2000);

经过测试发现并没有达到效果 SwipeRefreshLayout.setRefersh(true); 并没有运行,然后就去找资料,测试了一下有几种方法度可以达到效果,其中最简单的是如下:


SwipeRefreshLayout.setProgressViewOffset(false, 0, 30);

SwipeRefreshLayout.setRefersh(true);

new Handler().postDelay(new Runable{

        public void run(){

           //这里进行数据的加载

            SwipeRefreshLayout.setRefersh(false);

  ]

},2000);

只需在前面加上SwipeRefreshLayout.setProgressViewOffset(false, 0, 30);方法,那这个方法起到了什么作用呢?查看源码得知:

* The refresh indicator starting and resting position is always positioned
* near the top of the refreshing content. This position is a consistent
* location, but can be adjusted in either direction based on whether or not
* there is a toolbar or actionbar present.

三个参数的意思分别是:1.Scale表示这个Progress是否缩放 2.start和end就是那刷新进度条展示的相对于默认的展示位置,start和end组成一个范围,在这个y轴范围就是那个圆形进度ProgressView展示的位置。


  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值