I don't understand why Android's RatingBar widget doesn't scale to the width I specify in the layout.
If I have something simple like
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".home.view.TempActivity">
<androidx.cardview.widget.CardView
android:id="@+id/cardView"
android:layout_width="170dp"
android:layout_height="220dp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent">
<androidx.appcompat.widget.AppCompatRatingBar
android:id="@+id/ratingBar"
style="?attr/ratingBarStyleIndicator"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:isIndicator="true"
android:max="5"
android:numStars="5" />
</androidx.cardview.widget.CardView>
</androidx.constraintlayout.widget.ConstraintLayout>
The last star is cut off. Sure, I could use ratingBarStyleSmall
instead of ratingBarStyleIndicator
, but then it's too small. How can you get it so it simply scales to the width of the parent (in this case, a CardView at 170dp)?