PullToRefresh Demo 浅析:自定义刷新(refreshview)样式

本文探讨了PullToRefresh库在用户下拉和上拉时如何自定义刷新视图(refreshview)的样式。通过构造函数理解不同方向的布局选择,并提供了相关参考资料链接。
摘要由CSDN通过智能技术生成

PullToRefresh除了可以自己定制刷新的内容之外,最重要的还是在与当用户下拉和上拉时候的样式问题。


打开library源码,发现refreshview的样式定义在了LoadingLayout类中。
   public abstract class LoadingLayout extends FrameLayout implements ILoadingLayout {
  

构造函数中:

   switch (scrollDirection) {
            case HORIZONTAL:
                LayoutInflater.from(context).inflate(R.layout.pull_to_refresh_header_horizontal, this);
                break;
            case VERTICAL:
            default:
                LayoutInflater.from(context).inflate(R.layout.pull_to_refresh_header_vertical, this);
                break;
        }

可以看出根据不同的方向选用不同的布局,所以对于自定义refreshview来说,就是重新选择布局。

参考:http://www.2cto.com/kf/201501/368016.html


附带:PullToRefresh的自定义样式属性:
<?xml version="1.0" encoding="utf-8"?>
<resources>
  <declare-styleable name="PullToRefresh">
    <!-- A drawable to use as the background of the Refreshable View -->
    <!-- 设置整个刷新列表的背景色 -->
    <attr name="ptrRefreshableViewBackground" format="reference|color" />
    <!-- A drawable to use as the background of the Header and Footer Loading Views -->
    
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值