Android star rating how to fit width

I need an asterisk that can match the width of the car. When I try to resize a design screen; if the screen is small, some stars disappear (after the 5th or 6th), if the screen is large, all stars are visible.

How can I do it?

that's what i have

<RatingBar android:id="@+id/ratingBar1" android:layout_width="wrap_content" android:layout_height="wrap_content" android:numStars="10" android:rating="7" /> 
+6
source share
1 answer

U can't set the width, but you can use a custom rating bar, just add:

compile 'FlexibleRatingBar:flexibleratingbar:1.3'

This rating panel will automatically fit. Then you initialize, for example:

 ratingBar = new FlexibleRatingBar(this); ratingBar.setStepSize(1); ratingBar.setColorFillOn(Color.rgb(65,105,225)); ratingBar.setColorFillPressedOn(Color.rgb(135,206,235)); someLayout.addView(ratingBar); 
+1
source

Source: https://habr.com/ru/post/953194/


All Articles