Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Stars not reflecting user input #28

Open
samcackett opened this issue Nov 17, 2017 · 7 comments
Open

Stars not reflecting user input #28

samcackett opened this issue Nov 17, 2017 · 7 comments
Assignees

Comments

@samcackett
Copy link

I think this is a general issue with the RatingBar for Android, but wanted to post here to be sure as I couldn't find a definitive answer.

We have the MaterialRatingBar in our app (love it btw), using width=match_parent.

On some devices, when the user taps 1 star, the 2nd star updates. If they tap the 2nd star, the 3rd updates etc. User can never select 1 star and the star they select is never the correct one.

Samsung devices seem to suffer the worst with this issue. It works fine as well on plenty of devices. If we get rid of match_parent, it seems to work on all devices too.

@zhanghai
Copy link
Owner

Yes it might be that Samsung modified the framework RatingBar implementation and violated some contract. Since I don't have any Samsung device at hand, so I'd suggest that you try debugging the ClipDrawable.setLevel() and see if the framework RatingBar is passing the correct value, or if not so how is it different from desired value. I'd also check if this is a display issue with the drawable, or it is also wrong in RatingBar.getRating().

@samcackett
Copy link
Author

Thank you for getting back to me so quickly, I will take a look at this next week. Have a great weekend

@sismetanin
Copy link

This bug seems to be a result of RatingBar extending ProgressBar. It can be fixed by setting your stepSize to 0.01 and implementing custom RatingBar.OnRatingBarChangeListener.

ratingBar.setOnRatingBarChangeListener(new RatingBar.OnRatingBarChangeListener() {
    @Override
    public void onRatingChanged(final RatingBar ratingBar, final float rating, final boolean fromUser) {
        if (fromUser) {
            ratingBar.setRating(Math.ceil(rating));
        }
    }
});

For more details, please follow the link below: https://stackoverflow.com/a/35531397

@zhanghai
Copy link
Owner

zhanghai commented Dec 7, 2017

@sam9046 I wonder if you had fixed this bug?
(Although the fix @sismetanin mentioned is about wrap_content width and all devices)

@leoacevedo
Copy link

I confirm that sistematin's workaround does work.
And this happened to me on xhdpi emulators of different sizes, so definitely not Samsung-specific.

@zhanghai
Copy link
Owner

zhanghai commented Apr 9, 2018

@leoacevedo Is it specific to layout_width="match_parent"? Can you reproduce it with sample app on xhdpi emulators?

@jaildigger
Copy link

It's only reproduced on API level 24 (Android 7.0), I've checked on several devices with that version.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants