private void init(Context context, AttributeSet attrs, int defStyleAttr) {
TypedArray a = context.getTheme().obtainStyledAttributes(attrs, R.styleable.ColorRatingBar, defStyleAttr, 0);
int progressColor = a.getColor(R.styleable.ColorRatingBar_progress_color, ContextCompat.getColor(context, R.color.colorPrimary));
// int halfColor = a.getColor(R.styleable.ColorRatingBar_half_color, ContextCompat.getColor(context, R.color.colorAccent));
int emptyColor = a.getColor(R.styleable.ColorRatingBar_empty_color, ContextCompat.getColor(context, R.color.colorAccent));
boolean changeable = a.getBoolean(R.styleable.ColorRatingBar_changeable, true);
LayerDrawable stars = (LayerDrawable) getProgressDrawable();
// Filled stars
setRatingStarColor(DrawableCompat.wrap(stars.getDrawable(2)), progressColor);
// Half filled stars
setRatingStarColor(DrawableCompat.wrap(stars.getDrawable(1)), progressColor);
// Empty stars
setRatingStarColor(DrawableCompat.wrap(stars.getDrawable(0)), emptyColor);
setIsIndicator(!changeable);
}
ColorRatingBar.java 文件源码
java
阅读 18
收藏 0
点赞 0
评论 0
项目:ColorRatingBar
作者:
评论列表
文章目录