I am using
Android RatingBar change star colors
This line of code
LayerDrawable stars = (LayerDrawable) rating_bar.getProgressDrawable();
>
What happens is clearly explained in the error message :
TintDrawableWrapper cannot be cast to android.graphics.drawable.LayerDrawable
The support lib creates a wrapper in order to handle retro compatibility, you just need to take it into account. Have a look at the lib implementation, it probably wraps around a LayerDrawable
.
You will need to do something along the lines of :
LayerDrawable stars = getProgressDrawable(rating_bar);
}
private LayerDrawable getProgressDrawable(RatingBar ratingBar) {
if (Build.VERSION >= LOLLIPOP) {
return (LayerDrawable) ratingBar.getProgressDrawable();
} else {
// fetch the LayerDrawable based on Google's support implementation,
// probably a simple findViewById()
}
}