Rating bar showing only half stars instead of full stars - android

I'm working on an app that needs to create a non editable small style rating bar with 4 stars dynamically.
When I call setRating(4) it shows 4 stars without any problem.
But when I call setRating(3) it shows 3 and half stars.
setRating(2) shows 2 stars correctly,
but setrating(1) shows 1 and half stars.
When I use a normal rating bar in another activity it works fine, but when I use the small style non editable rating bar it doesn't work properly.
Does this have anything to do with the api level or small style non editable rating bar?
Initialization is done like this:
RatingBar ioRatingBar = new RatingBar(this,null,android.R.attr.ratingBarStyleSmall);
ioRatingBar.setNumStars(4);
ioRatingBar.setRating(3);

You need to set the step size of the RatingBar like this
ratingBar.setStepSize(1.0);
and also try to define the max rating as:
ratingBar.setMax(4);

If exist padding, remove. I suggest replace with margin.

Related

Can I set the rating bar size to match constraint?

I am finding "solutions" suggesting using the small rating bar style, or to just change the size of the stars with a custom style, but I don't want it to be fixed. I just want the 5 stars bar to match the constraints?
You can use flexible RatingBar
FlexibleRatingBar

Value overlapping issue in barchart of PhilJay/MPAndroidChart

In the chart section of the image, the value 1 is overlapping with value 19. I have used bar chart here.
Buddy its because the 1 value of above bar in stacked bar is low and you are drawing values inside bars. All you can do is try shifting values above bars but this can also overlap but give it a try. For that do the following:
chart.setDrawValueAboveBar(true);
Or you can change the color of values text as of colors of bars to differentiate for that you have to move values above bars so one can see that.

Android RatingBar shows less stars

I am trying to show a rating bar in a ListView.
No matter what I tried:
viewHolder.viewOnlyQuickRatingBar.setNumStars(5);
or:
android:numStars="5"
or both of the above I always get the same result.
In Android 5.0 I get a 5-star rating bar and in Android 4.1.2 I get 4-star rating bar.
The weird is when I try to show the rating bar (using the, above, xml code only) in Activity and not in a ListView everything is working just fine.
How can I get a 5-star rating bar under any circumstances?
From experience, adding :
style="?android:attr/ratingBarStyleSmall"
in your xml can help if your view has not enough place to draw 5 stars.

Having trouble with rating bar

I am playing with rating bar. I follow One good tutorial for customizing rating bar.
I am Facing some problem:
This tutorial use one image for rating bar but i don't want to use
any image for rating bar. i need to use android Rating bar widget.
When i use Android Rating widget it show too large or too small(when i use style="?android:attr/ratingBarStyleSmall">) with
having more than 10 star whether we set android:numStars="5" or not.
Ok. Suppose i use any image for that but when i set rating = 2.5 then
image still not change i use this method ratingBar.setRating(Float.parseFloat("2.0"));.
Here i use image for this rating bar
my code is same as which given above link.
Can you give me some reference by using i can use Rating bar widget in small shape with only 5 star?
I don't want to use any image i want to use only android rating widget.
I stuck here from last 5 hours.
Any help appreciated.

How to use Rating bar?

i would like to save the state of rating bar rating stars? How would i go about doing this?
and also how would i go about getting the number of stars the user has selected? To display in a textView?
Thanks
From developer.android.com :
http://developer.android.com/resources/tutorials/views/hello-formstuff.html#RatingBar
Other Example Here..
http://android-er.blogspot.com/2010/02/ratingbar.html
If you want to customize RatingBar eg. Displaying other image than default Star
refer How to create Custom Ratings bar in Android
This example shows Toast message when user selects Ratings.
& Obviously you will have to customize it according to your needs (as you told you want to display it in TextView).
You can define a TextView in xml file & set its text property when Rating has changed.

Categories

Resources