Android自定义View实现投票进度条

 更新时间:2019年11月20日 11:04:38   作者:姜丝儿jlq  
这篇文章主要为大家详细介绍了Android自定义View实现投票进度条,文中示例代码介绍的非常详细,具有一定的参考价值,感兴趣的小伙伴们可以参考一下

本文实例为大家分享了Android投票进度条的具体代码,供大家参考,具体内容如下

效果展示

功能属性介绍

<!-- MatchSupportProgressBar -->
  <declare-styleable name="MatchSupportProgressBar">
  <!-- 进度条圆角角度 -->
  <attr name="progress_radio" format="string"></attr>
  <!-- 进度条左侧Tag文本 -->
  <attr name="progress_tag_text" format="string"></attr>
  <!-- 进度条已填充部分颜色 -->
  <attr name="progress_reach_color" format="color"></attr>
  <!-- 进度条已填充部分高度 -->
  <attr name="progress_reach_height" format="dimension"></attr>
  <!-- 进度条背景颜色 -->
  <attr name="progress_background_color" format="color"></attr>
  <!-- 进度条背景高度 -->
  <attr name="progress_background_height" format="dimension"></attr>
  <!-- 进度条左侧Tag文本颜色 -->
  <attr name="progress_tag_text_color" format="color"></attr>
  <!-- 进度条左侧Tag文本尺寸 -->
  <attr name="progress_tag_text_size" format="dimension"></attr>
  <!-- 进度条右侧百分比文本颜色 -->
  <attr name="progress_percent_text_color" format="color"></attr>
  <!-- 进度条右侧百分比文本尺寸 -->
  <attr name="progress_percent_text_size" format="dimension"></attr>
  <!-- 进度条右侧百分比文本 -->
  <attr name="progress_percent_text" format="string"></attr>
  <!-- 进度条选中的图标与进度条、文字的间距 -->
  <attr name="progress_offsetX" format="dimension"></attr>
  <!-- 进度条右侧文字的水平偏移量 -->
  <attr name="progress_offsetR" format="dimension"></attr>
  <!-- 进度条之间的偏移量 -->
  <attr name="progress_LineSpacing" format="dimension"></attr>
</declare-styleable>

xml使用示例

<com.yjyc.supportprogress.view.MatchSupportProgressBar
  android:id="@+id/progressbar_match_support"
  android:layout_width="match_parent"
  android:layout_height="wrap_content"
  android:layout_marginTop="10dp"
  android:paddingLeft="3dp"
  android:paddingRight="3dp"
  android:progress="30"
  yjcp:progress_background_color="#333"
  yjcp:progress_background_height="30dp"
  yjcp:progress_offsetR="20dp"
  yjcp:progress_percent_text_color="#345698"
  yjcp:progress_percent_text_size="13sp"
  yjcp:progress_reach_color="#999"
  yjcp:progress_tag_text_color="#ffffff"
  yjcp:progress_tag_text="杰伦;那英;汪峰"
  yjcp:progress_tag_text_size="13sp" />

java使用示例

//进度条的点击事件监听
mspb.setOnRightTextClickListener(new OnRightTextClickListener() {

 @Override
 public void onClick(int position) {
 //position是点击的位置
 }
});
/*
为进度条赋值:
参数1:是我们算好的进度值,一般由服务器返回。(注: yjcp:progress_tag_text="杰伦;那英;汪峰"设置 了几个字符串,getPercentList就要传几个字符串)
参数2:得到一个boolean类型的集合,用于设置进度条√显示的位置
参数3:true表示已投票,false表示未投票
参数4:是否开启动画特效 
*/
mspb.setPercentState(getPercentList("10","90","100"), getCheckList(position), true, true);
//重置进度条状态,如果在listview中涉及到复用问题条用它即可。
//参数:true投过票,false未投过
mspb.setState(false);

源码下载:Android投票进度条

以上就是本文的全部内容,希望对大家的学习有所帮助,也希望大家多多支持脚本之家。

相关文章

  • mui.init()与mui.plusReady()区别和关系

    mui.init()与mui.plusReady()区别和关系

    给大家分享一下在使用MUI进行APP开发的时候,mui.init()与mui.plusReady()区别以及使用上不同之处。
    2017-11-11
  • Android实现上传文件到服务器实例详解

    Android实现上传文件到服务器实例详解

    本篇文章详细介绍了Android实现上传文件到服务器实例详解,实现了文件每隔5秒进行上传,有需要的可以了解一下。
    2016-11-11
  • PopupWindow自定义位置显示的实现代码

    PopupWindow自定义位置显示的实现代码

    这篇文章主要为大家详细介绍了PopupWindow自定义位置显示,具有一定的参考价值,感兴趣的小伙伴们可以参考一下
    2017-10-10
  • Android开发利器之pidcat安装方式

    Android开发利器之pidcat安装方式

    pidcat 是Android届JakeWharton大神开发的一款命令行工具,堪称Android开发利器,它能方便Android程序猿捕获日志,过滤日志,定位程序问题,超级好用。这篇文章给大家介绍了Android开发利器之pidcat,需要的朋友可以参考下
    2019-05-05
  • Android开发高仿课程表的布局实例详解

    Android开发高仿课程表的布局实例详解

    这篇文章主要介绍了Android开发高仿课程表的布局实例详解的相关资料,非常不错,具有参考借鉴价值,需要的朋友可以参考下
    2016-10-10
  • Android编程中的消息机制实例详解

    Android编程中的消息机制实例详解

    这篇文章主要介绍了Android编程中的消息机制,结合实例形式较为详细的分析了Android中消息机制的原理,注意事项与相关使用技巧,需要的朋友可以参考下
    2016-01-01
  • Android实现3D标签云效果

    Android实现3D标签云效果

    这篇文章主要为大家详细介绍了Android实现3D标签云效果,文中示例代码介绍的非常详细,具有一定的参考价值,感兴趣的小伙伴们可以参考一下
    2018-05-05
  • Android通过RemoteViews实现跨进程更新UI示例

    Android通过RemoteViews实现跨进程更新UI示例

    本篇文章主要介绍了Android通过RemoteViews实现跨进程更新UI示例,小编觉得挺不错的,现在分享给大家,也给大家做个参考。一起跟随小编过来看看吧
    2017-02-02
  • Android编程实现自定义toast示例

    Android编程实现自定义toast示例

    这篇文章主要介绍了Android编程实现自定义toast,结合简单实例形式分析了自定义布局toast核心实现技巧,具有一定参考借鉴价值,需要的朋友可以参考下
    2017-01-01
  • Android多媒体应用使用SoundPool播放音频

    Android多媒体应用使用SoundPool播放音频

    这篇文章主要为大家详细介绍了Android多媒体应用使用SoundPool播放音频,文中示例代码介绍的非常详细,具有一定的参考价值,感兴趣的小伙伴们可以参考一下
    2017-12-12

最新评论