I have a requirement to rate for a user with minimum of one star and after that ratings should increase to 0.5. But my question is that the user should not change the minimum rating of star to 0.5 or 0. 1 should be the default rating. Please help with this and awaiting for your earlier response. I also tried implementing by listeners from the link but completely struct with the logic inside My code is:
ratingBar.setOnRatingBarChangeListener(new OnRatingBarChangeListener() {
@Override public void onRatingChanged(RatingBar ratingBar, float rating,
boolean fromUser) {
}
});
A user can simply touch, drag or click on the stars to set the rating value. The value of rating always returns a floating point number which may be 1.0, 2.5, 4.5 etc. In Android, RatingBar is an extension of ProgressBar and SeekBar which shows a rating in stars.
Custom Rating Bar in AndroidCopy your images in the drawable folder and remember image size should be according to the size you want. Step 2. Make XML for the rating bar selector in the drawable folder like below. We made two files, one for the fill or highlighted part and one for the empty or un-highlighted part.
The ratingBar component does not allow to customize spacing between the stars.
ratingBar.setOnRatingBarChangeListener(new OnRatingBarChangeListener() {
@Override public void onRatingChanged(RatingBar ratingBar, float rating,
boolean fromUser) {
if(rating<1.0f)
ratingBar.setRating(1.0f);
}
});
Setting Rating takes float value , in Case ur value is String :
ratingBar.setRating(Float.parseFloat(result));
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