RatingBar color appears after Google Play Services 7.5.0 update
My app worked fine until I switched to "com.google.android.gms: play-services: 7.5.0". I used the RatingBar in a job that worked fine. But after the update, the Ratingbar color looks white. Even I tried to change the color using code and layout, but the color looks white. But when I touch the rating bar, a green indicator appears.
Code:
<RatingBar
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/ratingBar"
android:layout_gravity="center_horizontal"
android:numStars="5"
android:theme="@style/Theme.AppCompat.Light"
android:stepSize="0.5"
android:progressBackgroundTint="#ff048ec4"
android:progressTint="#ff048ec4"
android:progressBackgroundTintMode="multiply"
android:progressTintMode="multiply" />
The problem is only with versions below Lollipop. In Lollipop, there is no problem, but in Kitkat and lower versions the color appears white.
Does anyone know a solution for this? Thanks in Advance.
+3
source to share
1 answer
For API >= 21
Drawable progress = ratingBar.getProgressDrawable();
DrawableCompat.setTint(progress, Color.YELLOW);
For API < 21
RatingBar ratingBar = (RatingBar) findViewById(R.id.ratingBar);
LayerDrawable stars = (LayerDrawable) ratingBar.getProgressDrawable();
stars.getDrawable(2).setColorFilter(Color.YELLOW,PorterDuff.Mode.SRC_ATOP);
0
source to share