I have a standard implementation of a RatingBar
. 5 stars, 1 in stepsize.
<RatingBar
android:id="@+id/ratingBar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:numStars="5"
android:stepSize="1"
android:progressDrawable="@drawable/dark"
android:rating="@={viewModel.rating}"
/>
I have noticed that I have a problem on some devices, or brands actually: Samsung, Nexus, maybe more... But I don't have the issue on Sony and LG devices, maybe more here as well.
The problem is that the precision when selecting a value is really bad. It seems like if I pass the middle of the rating-drawable it will fill the following "star". It seems to be the threshold for those devices and that's just the way it is. They way the LG and Sony behaves is that when you pass half the distance between two "stars", then it fills in the next star.
So, is there anything I can do to prevent this?
As far as I know, there is no way around it.
I'm the creator of a library which provides an alternative to Android's default RatingBar: SimpleRatingBar, and we discussed this behaviour in one issue.
In the library, we modified this behaviour so one star will be selected only if at least 1/4 of it is pressed. I believe this improves the overall experience when using it.
If you want to, you can give it a try. It features:
android:layout_width
: it can be set to wrap_content
, match_parent
or abritary dp.Here is a preview of it
You can find it either in jcenter
or in Maven Central
. So in your build.gradle
file just add to your dependencies:
compile 'com.iarcuschin:simpleratingbar:0.1.+'
I hope it's useful.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With