RatingBar incorrectly selected

208 Views Asked by At
<LinearLayout>
    ...
    <androidx.appcompat.widget.AppCompatRatingBar
        android:id="@+id/starRatingBar"
        style="@style/yellowStarRatingBar"
        android:layout_width="wrap_content"
        android:layout_height="0dp"
        android:layout_gravity="center"
        android:layout_marginTop="@dimen/dp_10"
        android:layout_weight="0.5"
        android:numStars="5"
        android:rating="0"
        android:stepSize="1" />
    ...
</LinearLayout>

When I click on the right half of the , the next is also selected. Do any of you know what is going on?

1

There are 1 best solutions below

4
Ole Pannier On

Additionally, if you set a layout_weight, this supersedes the numStars attribute.

  <RatingBar
                android:id="@+id/starRatingBar"
                style="@style/yellowStarRatingBar"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_gravity="center"
                style="?android:attr/ratingBarStyleSmall"
                android:numStars="5"
                android:rating="0"
                android:stepSize="1" />