I want to change color of rating bar to golden.
I dont want to customize the stars, i just want to change the color for API 16 or above
I have tried following solutions but none of them worked out for me
1. RatingBar ratingBar = (RatingBar) findViewById(R.id.ratingBar); LayerDrawable stars = (LayerDrawable) ratingBar.getProgressDrawable(); stars.getDrawable(2).setColorFilter(Color.YELLOW, PorterDuff.Mode.SRC_ATOP); 2. android:progressDrawable="@color/golden" in XML
First, change progress color of rating bar. Its done by two ways, either by applying theme on RatingBar or by manually using LayerDrawable. That's it. android:stepSize="0.5" />LayerDrawable stars = (LayerDrawable) rating.
Step 1: After opening the android studio and creating a new project with an empty activity. Step 2: Navigate to res/values/colors. xml, and add a color that you want to change for the status bar. Step 3: In your MainActivity, add this code in your onCreate method.
After applying either style="? android:attr/ratingBarStyleSmall" or scaleX/scaleY the click interaction with RatingBar is disabled. This works for me. Hope this helps you!
RatingBar is used to get the rating from the app user. 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.
On API 21 and higher, you can change the color of the filled stars with
android:progressTint="@color/color"
and the color of the stroke with
android:progressBackgroundTint="@color/color"
This option is now included in the AppCompat library. The AppCompat version of the RatingBar is used automatically.
http://developer.android.com/reference/android/support/v7/widget/AppCompatRatingBar.html
Example (from my own app):
<RatingBar android:id="@+id/rating" android:layout_width="wrap_content" android:layout_height="wrap_content" android:numStars="5" android:stepSize="1" android:theme="@style/RatingBar"/>
With theme:
<style name="RatingBar" parent="Theme.AppCompat"> <item name="colorControlNormal">@color/lightGrey</item> <item name="colorControlActivated">@color/duskYellow</item> </style>
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