I am an android beginner and I want to make my custom ratingBar.
Disclaimer: it\'s not a duplicate. because all the posts I have read asks about how to change colors
Put all drawable color to Yellow(in your case getResources().getColor(R.color.gold) for all) for set strokes and background. (for background,secondary progress and progress)
RatingBar ratingBar = (RatingBar) findViewById(R.id.ratingBar);
LayerDrawable stars = (LayerDrawable) ratingBar.getProgressDrawable();
stars.getDrawable(2).setColorFilter(Color.YELLOW, PorterDuff.Mode.SRC_ATOP);
stars.getDrawable(0).setColorFilter(Color.YELLOW, PorterDuff.Mode.SRC_ATOP);
stars.getDrawable(1).setColorFilter(Color.YELLOW, PorterDuff.Mode.SRC_ATOP);
remove progressBackgroundTint,progressTint,secondaryProgressTint attributes from RatingBar no need of it.
and result is ::
Hope this will help (pink color is just background color)
after set drawable 1 and 0 to red:
RatingBar ratingBar = (RatingBar) findViewById(R.id.ratingBar);
LayerDrawable stars = (LayerDrawable) ratingBar.getProgressDrawable();
stars.getDrawable(2).setColorFilter(Color.YELLOW, PorterDuff.Mode.SRC_ATOP);
stars.getDrawable(0).setColorFilter(Color.Red, PorterDuff.Mode.SRC_ATOP);
stars.getDrawable(1).setColorFilter(Color.Red, PorterDuff.Mode.SRC_ATOP);