星星评价控件android开发_Android自定义view实现评分控件

最近需要做一个星星的评分控件(可以调整进度,进度颜色渐变)

如图:

image

image

一开始想到的是用系统自带的RatingBar做,但发现了一个问题,实现颜色渐变有点复杂,而且有好几个页面都用了这个,总不能都这样写吧。刚好这段时间看了HenCoder写的Android自定义view系列文章,于是就想自己尝试下实现一个评分控件,可以实现图案的替换,渐变颜色,进度背景,图案个数,大小等参数的自己控制,经过几天的折腾,终于完成了这个控件CBRatingBar

先上效果图:

image

image

image

image

gif效果图:

image

如何使用:

Gradle

在项目的build.gradle中添加如下代码:

allprojects {

repositories {

maven { url 'https://jitpack.io' }

}

}

在项目的build.gradle中引入该库:

dependencies {

compile 'com.github.CB-ysx:CBRatingBar:2.0.1'

}

使用方法

xml

android:layout_width="wrap_content"

android:layout_height="wrap_content"/>

android:layout_width="wrap_content"

android:layout_height="wrap_content"

app:starSize="20dp"

app:starCount="5"

app:starSpace="10dp"

app:starStrokeWidth="1dp"

app:starCanTouch="true"

app:starMaxProgress="120"

app:starProgress="60"

app:starShowStroke="true"

app:starUseGradient="true"

app:starStartColor="#0000ff"

app:starEndColor="#00ff00"

app:starCoverColor="#ff0000"

app:starFillColor="#666666"

app:

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值