Android-设置PullToRefresh下拉刷新样式
以下是开源控件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下拉刷新样式的更多相关文章
- Android PullToRefresh 下拉刷新,上拉很多其它,支持ScrollView,ListView,可方便拓展GridView,WebView等
在写着东西之前.从网上找到非常多这方面的源代码,可是基本没有找到惬意的.包含在GitHub上的比較有名的Android-PullToRefresh-master.思来想去还是自己写吧.当然当中借鉴了一 ...
- Android中实现下拉刷新
需求:项目中的消息列表界面要求实现类似sina微博的下拉刷新: 思路:一般的消息列表为ListView类型,将list加载到adapter中,再将adapter加载到 ListView中,从而实现消息 ...
- PullToRefresh 下拉刷新的样式修改
资源文件结构图, 先看看下拉刷新头的布局, <?xml version="1.0" encoding="utf-8"?> <merge xml ...
- Android PullToRefresh下拉刷新控件的简单使用
PullToRefresh这个开源库早就听说了,不过一直没用过.作为一个经典的的开源库,我觉得还是有必要认识一下. 打开github上的网址:https://github.com/chrisbanes ...
- .Net 转战 Android 4.4 日常笔记(10)--PullToRefresh下拉刷新使用
下拉刷新很多地方都用到了,新浪微博,微信,百度新闻 这里我们使用一个开源的库叫:PullToRefresh 开源地址:https://github.com/chenyoca/pull-to-refre ...
- Android StaggeredGrid 加下拉刷新功能 PullToRefresh
https://github.com/etsy/AndroidStaggeredGrid 用的github上面提供瀑布流,继承于abslistview,回收机制不错,并且提供了OnScrollLis ...
- android控件 下拉刷新pulltorefresh
外国人写的下拉刷新控件,我把他下载下来放在网盘,有时候訪问不了github 支持各种控件下拉刷新 ListView.ViewPager.WevView.ExpandableListView.GridV ...
- PullToRefresh下拉刷新 加载更多 详解 +示例
常用设置 项目地址:https://github.com/chrisbanes/Android-PullToRefresh a. 设置刷新模式 如果Mode设置成Mode.PULL_FROM_STAR ...
- pullToRefresh下拉刷新上拉加载
PullToRefresh 是一个第三方的工程. 之前的自定义下拉刷新控件貌似不太好用,于是网上找了这个. 参考:http://www.cnblogs.com/summers/p/4343964.ht ...
随机推荐
- [一个经典的多线程同步问题]解决方案三:互斥量Mutex
本篇通过互斥量来解决线程的同步,学习其中的一些知识. 互斥量也是一个内核对象,它用来确保一个线程独占一个资源的访问.互斥量与关键段的行为非常相似,并且互斥量可以用于不同进程中的线程互斥访问资源.使用互 ...
- phpcms自定义分页
在global.func.php中找到分页函数function pages($num, $curr_page, $perpage = 20, $urlrule = '', $array = array ...
- linux杂记(二)主机硬盘规划
linux安装过程中,至少要两个partition,一个是[/],另一个是虚拟内存[swap].但比较不保险. 稍微麻烦点的方式: / /usr:linux操作系统 /home:使用者信息 /var: ...
- 关于jQuery中的$.grep()方法的使用
数组筛选的方法,记录下,以加深印象. var ary = [1, 9, 3, 8, 6, 1, 5, 9, 4, 7, 3, 8, 6, 9, 1]; ary = $.grep(ary, functi ...
- 基于jQuery的Jsonp跨域[Get方式]
由于目前的项目需要无刷新的跨域操作数据,整理了下自己使用的基于jQuery的Jsonp跨域[Get方式]. 代码如下: Javascript部分 $(function(){ $.ajax({ asyn ...
- 基本数据结构简介--ath9k网卡驱动开发总结(二)
ath9k驱动代码主要数据结构概览. (1)在ath9k的驱动中,几乎是最顶层的数据结构是ath_softc,这个数据结构几乎随处可见.ath_softc是硬件与MAC层进行交互的中间载体,很多有用的 ...
- (14)[Xamarin.Android] 异步的网络图片下载
原文 [Xamarin.Android] 异步的网络图片下载 在设计要从网络上接大量数据并且显示在Android Listview中,而这些资料是利用Json格式传送并且数据中包含这图片档案. 那在X ...
- log4j.xml 为什么要使用SLF4J而不是Log4J
<?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE log4j:configuration SY ...
- 写个脚本列出neutron的ovs的topology。
运行结果如下: $ ./nova-ifinfo a7026868-407c-4c54-bb8f-a68623d7e13fvm name is: instance-00000035 # 查找VM ...
- openstack 采用conductor的原因
供参考. Tan0同学给我的解释: 两个原因 一个是为了isolation做准备 因为升级主要就是升DB的schema 如果让compute直接读写DB,那每次升级都得升compute 现在隔离开之后 ...