RatingBar colour appears White after upgrading Google Play Services 7.5.0

194 views Asked by At

My Application was running quite good until I upgraded to 'com.google.android.gms:play-services:7.5.0'. I was using the RatingBar in an activity which was working fine. But after upgrading, the Ratingbar color appears white. Even i tried to change the color using code and layout, but the color appears white. But when i touch the rating bar, some green coloured ratingbar 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 the versions lower than Lollipop. There is no issue in Lollipop, but in Kitkat & lower versions the color appears white.

Does anyone know the solution for this? Thanks in Advance.

1

There are 1 answers

0
HassanUsman On

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);