以下是开源控件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 -->
<!-- 设置下拉Header或者上拉Footer的背景色 -->
<attr name="ptrHeaderBackground" format="reference|color" />
<!-- Text Color of the Header and Footer Loading Views -->
<!-- 用于设置Header与Footer中文本的颜色 -->
<attr name="ptrHeaderTextColor" format="reference|color" />
<!-- Text Color of the Header and Footer Loading Views Sub Header -->
<!-- 用于设置Header与Footer中上次刷新时间的颜色 -->
<attr name="ptrHeaderSubTextColor" format="reference|color" />
<!-- Mode of Pull-to-Refresh that should be used -->
<attr name="ptrMode">
<flag name="disabled" value="0x0" /><!-- 禁用下拉刷新 -->
<flag name="pullFromStart" value="0x1" /><!-- 仅支持下拉刷新 -->
<flag name="pullFromEnd" value="0x2" /><!-- 仅支持上拉刷新 -->
<flag name="both" value="0x3" /><!-- 上拉刷新和下拉刷新都支持 -->
<flag name="manualOnly" value="0x4" /><!-- 只允许手动触发 --> <!-- These last two are depreacted -->
<flag name="pullDownFromTop" value="0x1" />
<flag name="pullUpFromBottom" value="0x2" />
</attr>
<!-- Whether the Indicator overlay(s) should be used -->
<!-- 如果为true会在mPullRefreshListView中出现icon,右上角和右下角,挺有意思的 -->
<attr name="ptrShowIndicator" format="reference|boolean" />
<!-- Drawable to use as Loading Indicator. Changes both Header and Footer. -->
<!-- 同时改变头部和底部的图标 -->
<attr name="ptrDrawable" format="reference" />
<!-- Drawable to use as Loading Indicator in the Header View. Overrides value set in ptrDrawable. -->
<!-- 头部视图的图标-->
<attr name="ptrDrawableStart" format="reference" /> <!-- Drawable to use as Loading Indicator in the Footer View. Overrides value set in ptrDrawable. -->
<!-- 底部视图的图标 -->
<attr name="ptrDrawableEnd" format="reference" />
<!-- Whether Android's built-in Over Scroll should be utilised for Pull-to-Refresh. -->
<attr name="ptrOverScroll" format="reference|boolean" />
<!-- Base text color, typeface, size, and style for Header and Footer Loading Views -->
<!-- 分别设置拉Header或者上拉Footer中字体的类型颜色等等 -->
<attr name="ptrHeaderTextAppearance" format="reference" />
<!-- Base text color, typeface, size, and style for Header and Footer Loading Views Sub Header -->
<attr name="ptrSubHeaderTextAppearance" format="reference" />
<!-- Style of Animation should be used displayed when pulling. -->
<attr name="ptrAnimationStyle">
<flag name="rotate" value="0x0" /><!-- flip(翻转动画), rotate(旋转动画) -->
<flag name="flip" value="0x1" />
</attr>
<!-- Whether the user can scroll while the View is Refreshing -->
<!-- 刷新的时候,是否允许ListView或GridView滚动 -->
<attr name="ptrScrollingWhileRefreshingEnabled" format="reference|boolean" />
<!--
Whether PullToRefreshListView has it's extras enabled. This allows the user to be
able to scroll while refreshing, and behaves better. It acheives this by adding
Header and/or Footer Views to the ListView.
-->
<!-- 决定了Header,Footer以何种方式加入mPullRefreshListView,true为headView方式加入,就是滚动时刷新头部会一起滚动 -->
<attr name="ptrListViewExtrasEnabled" format="reference|boolean" />
<!--
Whether the Drawable should be continually rotated as you pull. This only
takes effect when using the 'Rotate' Animation Style.
-->
<attr name="ptrRotateDrawableWhilePulling" format="reference|boolean" />
<!-- BELOW HERE ARE DEPRECEATED. DO NOT USE. -->
<attr name="ptrAdapterViewBackground" format="reference|color" />
<attr name="ptrDrawableTop" format="reference" />
<attr name="ptrDrawableBottom" format="reference" />
</declare-styleable>
</resources>

可以在布局文件中设置自定义的这些样式,使用方法如下:

<com.handmark.pulltorefresh.libaray                
xmlns:ptr="http://schemas.android.com/apk/res-auto"
android:id="@+id/lv"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/white"
android:cacheColorHint="#00000000"
android:divider="@drawable/border"
android:fadingEdge="none"
android:fadingEdgeLength="0dip"
android:scrollbars="none"
android:scrollingCache="true"
ptr:ptrDrawable="@drawable/infzm_logo"
/>

注意:需要声明命名空间:xmlns:ptr=http://schemas.android.com/apk/res-auto

使用自定义属性:ptr:ptrDrawable="@drawable/logo"

其他属性使用方法类似。

Android-设置PullToRefresh下拉刷新样式的更多相关文章

  1. Android PullToRefresh 下拉刷新,上拉很多其它,支持ScrollView,ListView,可方便拓展GridView,WebView等

    在写着东西之前.从网上找到非常多这方面的源代码,可是基本没有找到惬意的.包含在GitHub上的比較有名的Android-PullToRefresh-master.思来想去还是自己写吧.当然当中借鉴了一 ...

  2. Android中实现下拉刷新

    需求:项目中的消息列表界面要求实现类似sina微博的下拉刷新: 思路:一般的消息列表为ListView类型,将list加载到adapter中,再将adapter加载到 ListView中,从而实现消息 ...

  3. PullToRefresh 下拉刷新的样式修改

    资源文件结构图, 先看看下拉刷新头的布局, <?xml version="1.0" encoding="utf-8"?> <merge xml ...

  4. Android PullToRefresh下拉刷新控件的简单使用

    PullToRefresh这个开源库早就听说了,不过一直没用过.作为一个经典的的开源库,我觉得还是有必要认识一下. 打开github上的网址:https://github.com/chrisbanes ...

  5. .Net 转战 Android 4.4 日常笔记(10)--PullToRefresh下拉刷新使用

    下拉刷新很多地方都用到了,新浪微博,微信,百度新闻 这里我们使用一个开源的库叫:PullToRefresh 开源地址:https://github.com/chenyoca/pull-to-refre ...

  6. Android StaggeredGrid 加下拉刷新功能 PullToRefresh

    https://github.com/etsy/AndroidStaggeredGrid  用的github上面提供瀑布流,继承于abslistview,回收机制不错,并且提供了OnScrollLis ...

  7. android控件 下拉刷新pulltorefresh

    外国人写的下拉刷新控件,我把他下载下来放在网盘,有时候訪问不了github 支持各种控件下拉刷新 ListView.ViewPager.WevView.ExpandableListView.GridV ...

  8. PullToRefresh下拉刷新 加载更多 详解 +示例

    常用设置 项目地址:https://github.com/chrisbanes/Android-PullToRefresh a. 设置刷新模式 如果Mode设置成Mode.PULL_FROM_STAR ...

  9. pullToRefresh下拉刷新上拉加载

    PullToRefresh 是一个第三方的工程. 之前的自定义下拉刷新控件貌似不太好用,于是网上找了这个. 参考:http://www.cnblogs.com/summers/p/4343964.ht ...

随机推荐

  1. 浅谈C中的指针和数组(七)

    现在到揭露数组名本质的时候了,先给出三个结论: (1)数组名的内涵在于其指代实体是一种数据结构,这种数据结构就是数组: (2)数组名的外延在于其可以转换为指向其指代实体的指针,而且是一个指针常量: ( ...

  2. create mysql database

    CREATE DATABASE IF NOT EXISTS yourdbname DEFAULT CHARSET utf8 COLLATE utf8_general_ci;

  3. QF——网络之网络请求的几种方式,图片缓存

    同步请求和异步请求: 同步请求会阻塞主线程:不会开启新的线程,还是主线程,所以直到请求成功后,才能执行其它操作. 异步请求不会阻塞主线程.开启新的线程去请求服务器,而不影响用户的交互操作等其他动作. ...

  4. linux开机自动挂载NTFS-WINDOWS分区

    1.安装ntfs-3g-2009.4.4.tgz 2.输入fdisk -l 看一下分区 由此可见:/dev/sda5,6,7 即是windows下的D,E,F盘(NTFS格式). 3.vim /etc ...

  5. J2SE知识点摘记(七)

    1.        枚举的用法 enum 枚举名{枚举值表标};例子:"enum weekday{sun,mon,tue,wed,fri,sat}a,b,c;" For循环语句中使 ...

  6. C#版-百度网盘API的实现(二)

    在这篇文章中,我们通过代码来实现百度网盘的简单操作, 一,登陆,在代码中,我有一个Baidu1的类,实例化该类时回执行登陆方法,该类对外开放了三个方法, 1,GetFileDir获取根目录下的文件夹及 ...

  7. outlook 2007如何设置自动转发功能

    "工具" => "规则和通知" => 新建规则 => "邮件到达时检查" => 设置你的条件,比如发件人是谁,主题是 ...

  8. Image editing techniques and algorithms using Qt

    费了好半天劲先翻译这一点.还有好多地方不明白.先弄明白这一点.继续以后的翻译. 这一篇文章我们将讨论不同的技术和算法来修改图像使用Qt.但是在这之前我们继续你必须知道一些原则处理图片. 这里主要有两种 ...

  9. Android_按钮被按下效果的实现(selector选择器)

    在很多刚入门的新手在开发实例的过程中,经常会遇到要按下某个ImageView时,需要加入确认感的时候.需要在按下的时候,控制ImageVIew内图片的显示. 在我是新手的时候,也这样做过.所以这里简单 ...

  10. KJFrameForAndroid框架学习----高效设置网络图片

    KJFrameForAndroid框架项目地址:https://github.com/kymjs/KJFrameForAndroid 或备用地址http://git.oschina.net/kymjs ...