0

i have the following rating bar:

 final RatingBar rating = new RatingBar(mContext);
        rating.setStepSize(1);
        rating.setMax(5);
 }

Now I want to change the color for ratingbar for API 14.

I have write the following code:

rating.setProgressTintList(mContext.getResources().getColorStateList(R.color.colorAccent));

But this is working with above API 21.

I want to set this color for API 14.

How can I do this?

Suriyaa
  • 2,222
  • 2
  • 25
  • 44

1 Answers1

0

you can use this website to create color dependent widgets from this

http://android-holo-colors.com/

make your own style in for the Ratting or any other widget you want change something in. like this...

<style name="MyRatting" parent="android:Widget.Holo.Light.RatingBar">
    <item name="android:background">@drawable/apptheme_spinner_background_holo_light</item>
 ..... keep changing desired items 
</style>

after this apply this style to the main style which your application is referencing to something like this

<style name="AppThemeTest" parent="Theme.AppCompat.Light.NoActionBar">
    <!-- Customize your theme here. -->

    <item name="android:ratingBarStyle">@style/MyRatting</item>
</style>

sometime the application may not be able to pick up your given style to the application for respective Widget in that case directly apply the style to the Widget something like this

<RatingBar
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    style="@style/MyRatting"
    android:id="@+id/ratingBar" />
Pankaj Nimgade
  • 4,529
  • 3
  • 20
  • 30