I suppose you're looking for color tint:
ratingBar.setOnRatingBarChangeListener(new RatingBar.OnRatingBarChangeListener() {
@Override
public void onRatingChanged(RatingBar ratingBar, float rating, boolean fromUser) {
final LayerDrawable layerDrawable = (LayerDrawable) ratingBar.getProgressDrawable();
int color;
switch ((int) rating) {
case 1:
color = Color.RED;
break;
case 2:
case 3:
color = Color.YELLOW;
break;
case 4:
default:
color = Color.GREEN;
break;
}
DrawableCompat.setTint(DrawableCompat.wrap(layerDrawable.getDrawable(2)), color);
}
});
It works not very smooth, but it should be a point to start.

Also, you can set the color tint in touch listener - that way will be better for you, I guess:
ratingBar.setOnTouchListener(new View.OnTouchListener() {
private int lastColoredProgress = 0;
@Override
public boolean onTouch(View v, MotionEvent event) {
int progress = ratingBar.getProgress();
if (progress != lastColoredProgress) {
lastColoredProgress = progress;
final LayerDrawable layerDrawable = (LayerDrawable) ratingBar.getProgressDrawable();
int color;
switch (lastColoredProgress) {
case 0:
case 1:
color = Color.RED;
break;
case 2:
case 3:
color = Color.YELLOW;
break;
case 4:
default:
color = Color.GREEN;
break;
}
DrawableCompat.setTint(DrawableCompat.wrap(layerDrawable.getDrawable(2)), color);
}
return false;
}
});
