The minimum rating can be 0, negative numbers are not allowed.
However, you can create a rating bar with 11 stars to represent the values (-5 to +5)
In the listener of the rating bar, map the value to the range of -5 to +5 (by subtracting 6 from the parameter received) dynamically change the color as follows:
- 0 : Blue
- Negative value : Red
- Positive value : Green
So, the output will look like this:

Activity:
import android.app.Activity;
import android.graphics.Color;
import android.graphics.PorterDuff;
import android.graphics.drawable.LayerDrawable;
import android.os.Bundle;
import android.widget.RatingBar;
import android.widget.RatingBar.OnRatingBarChangeListener;
import android.widget.TextView;
public class MainActivity extends Activity {
private RatingBar ratingBar;
private TextView tvRating;
private LayerDrawable stars;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.original_activity_main);
ratingBar = (RatingBar) findViewById(R.id.ratingBar);
tvRating = (TextView) findViewById(R.id.value);
stars = (LayerDrawable) ratingBar.getProgressDrawable();
ratingBar.setOnRatingBarChangeListener(new OnRatingBarChangeListener() {
public void onRatingChanged(RatingBar ratingBar, float ratingValue,
boolean fromUser) {
int value = (int) (ratingValue) - 6;
tvRating.setText(String.valueOf(value));
int color = Color.BLUE;
if(value > 0)
color = Color.GREEN;
else if(value < 0)
color = Color.RED;
stars.getDrawable(2).setColorFilter(color, PorterDuff.Mode.SRC_ATOP);
}
});
}
}
XML:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent" >
<TextView
android:id="@+id/label"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Result : " />
<TextView
android:id="@+id/value"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_toRightOf="@+id/label"
android:text="" />
<RatingBar
android:id="@+id/ratingBar"
style="?android:attr/ratingBarStyleSmall"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@+id/label"
android:isIndicator="false"
android:numStars="11"
android:rating="0.0"
android:stepSize="1.0" />
</RelativeLayout>