Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7182689
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T17:49:24+00:00 2026-05-28T17:49:24+00:00

I have a custom RatingBar in my app that should display either the site

  • 0

I have a custom RatingBar in my app that should display either the site average rating or the user rating for a movie if a user has rated it. The color should change depending on whether the rating displayed is the site average or a user rating.

Here’s the process:
User views movie. Site average rating for the movie is displayed.

Layout code for the RatingBar:

<RatingBar android:id="@+id/ratingBar" android:isIndicator="true" 
    android:layout_margin="10dip" style="@style/RatingBar"
    android:progressDrawable="@drawable/site_rating_bar" android:stepSize="0.1" />

RatingBar style:

<style name="RatingBar" parent="@android:style/Widget.RatingBar">
    <item name="android:numStars">10</item>
    <item name="android:layout_width">wrap_content</item>
    <item name="android:layout_height">wrap_content</item>
    <item name="android:minHeight">30dip</item>
    <item name="android:maxHeight">30dip</item>
</style>

site_rating_bar.xml:

<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
   <item android:id="@+android:id/background"
      android:drawable="@drawable/btn_rating_star_off" />
   <item android:id="@+android:id/secondaryProgress"
      android:drawable="@drawable/btn_rating_star_off" />
   <item android:id="@+android:id/progress"
      android:drawable="@drawable/btn_site_rating_star_on" />
</layer-list>

The user can click on the RatingBar and bring up a dialog where they can add their own custom rating of the movie. Upon close of the dialog, the code updates the rating displayed in the RatingBar above. I’d like to also change the ProgressDrawable so that the color of the stars changes to indicate the user has added a custom rating.

But when I try to set the ProgressDrawable programmatically it does update it so it’s displaying the right color, but it only displays a single star, stretched across the screen.

ratingBar.setProgressDrawable(thisActivity.getResources().getDrawable(R.drawable.user_rating_bar));

user_rating_bar.xml:

<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
    <item android:id="@+android:id/background"
      android:drawable="@drawable/btn_rating_star_off" />
    <item android:id="@+android:id/secondaryProgress"
      android:drawable="@drawable/btn_rating_star_off" />
    <item android:id="@+android:id/progress"
      android:drawable="@drawable/btn_user_rating_star_on" />
</layer-list>

I’ve tried saving the original bounds and resetting them, but it didn’t help:

Rect bounds = ratingBar.getProgressDrawable().getBounds();  
ratingBar.setProgressDrawable(thisActivity.getResources().getDrawable(R.drawable.user_rating_bar));
ratingBar.getProgressDrawable().setBounds(bounds);

Also tried resetting the numStars in case it had gotten lost.

Any ideas greatly appreciated. TIA. 🙂

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-28T17:49:25+00:00Added an answer on May 28, 2026 at 5:49 pm

    I’m going through this same thing right now…I can’t for the life of me get it to work as expected through code, so I’m going the janky-layout route. 🙁

    <RatingBar
      android:id="@+id/beer_rating"
      android:numStars="5"
      android:progressDrawable="@drawable/rating_bar"
      android:indeterminateDrawable="@drawable/rating_bar"
      android:stepSize="0.5"
      android:isIndicator="true"
      android:layout_gravity="center"
      style="?android:attr/ratingBarStyleSmall" />
    <RatingBar
      android:id="@+id/beer_rating_average"
      android:indeterminateDrawable="@drawable/rating_bar_average"
      android:isIndicator="true"
      android:layout_gravity="center"
      android:numStars="5"
      android:progressDrawable="@drawable/rating_bar_average"
      android:stepSize="0.5"
      android:visibility="gone"
      style="?android:attr/ratingBarStyleSmall"/>
    

    Then just flipping the visibility on them when needed:

    findViewById(R.id.beer_rating).setVisibility(View.GONE);
    findViewById(R.di.beer_rating_average).setVisibility(View.VISIBLE);
    

    Sucks, but it works. Let me know if you come up with any other solves.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have used custom listview and custom rating bar. If I add that custom
I have custom classes that I currently instantiate within App.xaml as resources. I want
I have custom event that has several different subscribers who will all use the
I have custom gallery. Gallery represents items that are frame layout. There are one
I have custom component that I can place in my layout file (XML) for
Iam building a custom rating bar. With help of kozyr's article i have created
I have custom button, with an image that I'd like to shift down within
I have custom class that implement IEnumerable<int[]> interface and save current Enumerator . When
I have custom slider that I use the following touch event to respond to:
I have custom JSP tags that generate some HTML content, along with some javascript

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.