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 -->