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

发布时间:2021-09-27 13:52:09 作者:小新
来源:亿速云 阅读:125

这篇文章给大家分享的是有关Android如何自定义View实现投票进度条的内容。小编觉得挺实用的,因此分享给大家做个参考,一起跟随小编过来看看吧。

具体内容如下

效果展示

功能属性介绍

<!-- 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如何自定义View实现投票进度条”这篇文章就分享到这里了,希望以上内容可以对大家有一定的帮助,让大家可以学到更多知识,如果觉得文章不错,可以把它分享出去让更多的人看到吧!

推荐阅读:
  1. 小程序实现投票进度条
  2. Android自定义View如何实现圆环进度条

免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。

android view

上一篇:Linux系统性能优化的两个重要参数是什么

下一篇:SecureCRT用ssh key登录配置的方法是怎样的

相关阅读

您好,登录后才能下订单哦!

密码登录
登录注册
其他方式登录
点击 登录注册 即表示同意《亿速云用户服务条款》