views:

49

answers:

2

Hi!

I am following the standard example of how to add a RatingBar. To control the number of stars I tried to use android:numStars="5". The problem is that the number of stars doesn't seem to do anything at all. In portrait-layout I get 6 stars and when I flip the phone I get about 10 stars. I tried to set the number of stars in my Activity (myBar.setNumStars(5) ) that loads the xml but there was no success with that option either.

So my question is how do I define my layout so that it will only show five stars? Set numStars doesn't seem to work.

Thanks in advance Roland

+1  A: 
<RatingBar
            android:id="@+id/rating"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            style="?android:attr/ratingBarStyleSmall"
            android:numStars="5"
            android:stepSize="0.1"
            android:isIndicator="true" />

in code

mRatingBar.setRating(int)
Alex Volovoy
Thanks for your answer. The problem was that you can't use android:layout_width="fill_parent" since the RatingBar apperenty ignores the android:numStars othervise. :-/
A: 

The default value is set with andoid:rating in the xml layout.

Kevin Gaudin