How can i change the star colors and how can i change the size of the stars ?
相关问题
- How can I create this custom Bottom Navigation on
- Bottom Navigation View gets Shrink Down
- How to make that the snackbar action button be sho
- Listening to outgoing sms not working android
- How to create Circular view on android wear?
相关文章
- android开发 怎么把图片放入drawable的文件夹下
- android上如何获取/storage/emulated/下的文件列表
- androidStudio有个箭头不认识
- SQLite不能创建表
- Windows - Android SDK manager not listing any plat
- Animate Recycler View grid when number of columns
- Why is the app closing suddenly without showing an
- Android OverlayItem.setMarker(): Change the marker
So I have been struggling with this issue for two hours and I have come up with a working solution for all API versions, where half stars ratings are also shown.
You call the method with this order of drawables:
NOTE: Also you must specify attributes "max" and "numStars" in XML, otherwise half stars aren't shown.
A bit late answer but i hope it will help some folks.
And here is what the WhiteRatingStar looks like
With this the stars will be coloured in white for example.
Works for Android below and above version 21
After some research I've come up with this method to set the background tint, the gap tint (ex: half star) and the star tint color.
The simpliest way:
Try this, if you only want to change color:
Using the answers above, I created a quick static method that can easily be re-used. It only aims at tinting the progress color for the activated stars. The stars that are not activated remain grey.
Just pass your rating bar and a Color using
getResources().getColor(R.color.my_rating_color)
As you can see, I use DrawableCompat so it's backward compatible.
EDIT : This method does not work on API21 (go figure why). You end up with a NullPointerException when calling setProgressBar. I ended up disabling the whole method on API >= 21.
For API >= 21, I use SupperPuccio solution.