rating Bar does not get certain numbers (integer) of stars

Asked

Viewed 321 times

0

Hello, I’m using a rating bar in android studio and I used the following in the layout:

<RatingBar
   android:id="@+id/ratingBar"
   style="?android:attr/ratingBarStyleSmall"
   android:layout_height="wrap_content"
   android:layout_gravity="center_horizontal"
   android:background="#ffffff"
   android:isIndicator="false"
   android:numStars="5"
   android:padding="5dp"
   android:stepSize="1"
   android:layout_width="wrap_content" />

Turns out there’s no way she gets five stars, she gets four and a little bit of five. Does anyone know how to fix this? Thank you.

  • hello @Elaine Breda Schwaner, try setar android:layout_width="match_parent" instead of android:layout_width="wrap_content"

  • Thanks for the answer, but I’ve tried this. What happens with the match is that there appears much more than 5 stars.

  • I’ve never used it in my apps, but I’ll do some tests here, if you can

  • Ready, tested there, I put android:numStars="6" and came up at 5 o'clock in the morning. Thanks for giving me this tip, I had never really found myself for this component, I laughed

  • In mine, it didn’t work... If I put 6 appears 5 and a little bit of 6

  • try then to android:layout_width="90dp"for example and decreasing or increasing the value of widith until the one that is half gone, here in mine is normal regardless of the number of Stars I use

  • No gave. Because then it varies the number of stars according to the size of the user’s phone

Show 2 more comments

1 answer

1


opa, entaum confirma ai se isso que Voce precisa

<RatingBar
    android:id="@+id/ratingBar"
    style="?android:attr/ratingBarStyleSmall"
    android:layout_height="wrap_content"
    android:layout_gravity="center_horizontal"
    android:background="#ffffff"
    android:isIndicator="false"
    android:numStars="5"
    android:padding="0dp"
    android:stepSize="1"
    android:layout_width="wrap_content">
</RatingBar>

note that when using padding="5dp" I used padding="0dp" dai worked round, see on the screens: inserir a descrição da imagem aqui inserir a descrição da imagem aqui

Browser other questions tagged

You are not signed in. Login or sign up in order to post.