[add] 个人中心与热心指数心形区分 自定义属性
This commit is contained in:
@@ -77,6 +77,11 @@ public class CustomRatingBar extends LinearLayout {
|
||||
* */
|
||||
private StepSize stepSize;
|
||||
|
||||
/*
|
||||
*添加资源(空白心是白色还是灰色自定义属性)
|
||||
* */
|
||||
private boolean otherHeartImg;
|
||||
|
||||
@Override
|
||||
public boolean isClickable() {
|
||||
return mClickable;
|
||||
@@ -159,14 +164,21 @@ public class CustomRatingBar extends LinearLayout {
|
||||
context.getResources().getDimension(R.dimen.heart_ratingbar_height));
|
||||
elementPadding = mTypedArray.getDimension(R.styleable.CustomRatingBar_elenmentPadding,
|
||||
context.getResources().getDimension(R.dimen.ratingbar_padding));
|
||||
/*
|
||||
* 白天模式下 热心指数(白色)和个人中心(灰色)使用不同的资源
|
||||
* 默认灰色
|
||||
* */
|
||||
otherHeartImg = mTypedArray.getBoolean(R.styleable.CustomRatingBar_OtherHeartImg, true);
|
||||
|
||||
elementStep = mTypedArray.getFloat(R.styleable.CustomRatingBar_elenmentStep, 1.0f);
|
||||
stepSize = StepSize.fromStep(mTypedArray.getInt(R.styleable.CustomRatingBar_stepSize, 1));
|
||||
elementCount = mTypedArray.getInteger(R.styleable.CustomRatingBar_elenmentCount, 5);
|
||||
stepSize = StepSize.Half;
|
||||
|
||||
Drawable drawable_empty_default = ContextCompat.getDrawable(context, R.drawable.icon_heart_unchoose);
|
||||
Drawable drawable_harf_default = ContextCompat.getDrawable(context, R.drawable.icon_heart_second);
|
||||
Drawable drawable_empty_default = ContextCompat.getDrawable(context,
|
||||
otherHeartImg == false ? R.drawable.icon_heart_unchoose : R.drawable.icon_heart_unchoose_other);
|
||||
Drawable drawable_half_default = ContextCompat.getDrawable(context,
|
||||
otherHeartImg == false ? R.drawable.icon_heart_second : R.drawable.icon_heart_second_other);
|
||||
Drawable drawable_fill_default = ContextCompat.getDrawable(context, R.drawable.icon_heart_choose);
|
||||
|
||||
Drawable drawable_empty = mTypedArray.getDrawable(R.styleable.CustomRatingBar_elenmentEmpty);
|
||||
@@ -175,7 +187,7 @@ public class CustomRatingBar extends LinearLayout {
|
||||
|
||||
elementEmptyDrawable = drawable_empty != null ? drawable_empty : drawable_empty_default;
|
||||
elementFillDrawable = drawable_half != null ? drawable_half : drawable_fill_default;
|
||||
elementHarfDrawable = drawable_fill != null ? drawable_fill : drawable_harf_default;
|
||||
elementHarfDrawable = drawable_fill != null ? drawable_fill : drawable_half_default;
|
||||
mClickable = mTypedArray.getBoolean(R.styleable.CustomRatingBar_clickable, false);
|
||||
mTypedArray.recycle();
|
||||
for (int i = 0; i < elementCount; ++i) {
|
||||
|
||||
Reference in New Issue
Block a user