Android-设置PullToRefresh下拉刷新样式

摘要:
Android-设置PullToRefresh下拉刷新样式以下是开源控件PullToRefresh的自定义样式属性:˂!

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.PullToRefreshListView          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下拉刷新样式》仅用于学习参考。如对内容有疑问,请及时联系本站处理。

上篇PHP 内置函数fgets读取文件Android ANR详解下篇

宿迁高防,2C2G15M,22元/月;香港BGP,2C5G5M,25元/月 雨云优惠码:MjYwNzM=

相关文章

Nginx tomcat集群 转发后端口丢失

场景: 阿里云主机 docker 搭建nginx集群,访问项目端口丢失 配置如下: 丢失的可能原因: proxy_set_header Host设置不对,修改如下: proxy_set_header Host $http_host; proxy_set_header Host 可以设置有如下几种: proxy_set_header Host $prox...

less 官网讲解 ( http://www.bootcss.com/p/lesscss/ )

变量 变量允许我们单独定义一系列通用的样式,然后在需要的时候去调用。所以在做全局样式调整的时候我们可能只需要修改几行代码就可以了。 // LESS @color: #4D926F; #header { color: @color; } h2 { color: @color; } /* 生成的 CSS */ #header { co...

nginx 获取请求头,URL参数

获取url参数 在 ngx_lua 中访问 Nginx 内置变量 ngx.var.arg_PARAMETER 即可获得GET参数PARAMETER的内容。 在 nginx配置中,通过$arg_PARAMETER 即可获得GET参数PARAMETER的内容。 获取请求头 在 ngx_lua 中访问 Nginx 内置变量 ngx.var.http_HEA...

wireshark源码分析二

一、源代码结构 在wireshark源代码根目录下,可以看到以下子目录: 1)物理结构     其中,epan文件夹负责所有网络协议识别工作,plugins里面存放了wireshark所有插件,gtk文件夹里面是wireshark的界面部分代码,其余文件夹没有单独研究。 2)逻辑结构     下图给出了Ethereal功能模块:    a) GTK1/2...

AG-Admin微服务框架入门

  AG-Admin微服务框架入门  @qq群:一群: 837736451  二群 169824183 一 概要介绍 AG-Admin后台地址:https://gitee.com/minull/ace-security AG-Admin前端地址:https://gitee.com/minull/AG-Admin-v2.0 要想玩儿转spring cloud...

js对flv提取h264、aac音视频流

FLV提取里面的h264视频流 FLV和MP4支持的编码 流媒体和媒体文件的区别 流媒体是指将一连串的多媒体资料压缩后,经过互联网分段发送资料,在互联网上即时传输影音以供观赏的一种技术与过程,此技术使得资料数据包得以像流水一样发送,如果不使用此技术,就必须在使用前下载整个媒体文件。flv属于流媒体格式,所以很适合做低延时的直播 对比hls和mp4 相对于...