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

  • Home
  • SEARCH
  • 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 4550304
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 21, 20262026-05-21T16:28:41+00:00 2026-05-21T16:28:41+00:00

Hello all i need to perform Ratings in my application… SO i need to

  • 0

Hello all i need to perform Ratings in my application… SO i need to create custom Ratings bar… Can Anyone Help me in this?

  • 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-21T16:28:42+00:00Added an answer on May 21, 2026 at 4:28 pm

    styles.xml

    This must be located in your values folder

     <?xml version="1.0" encoding="utf-8"?>
      <resources>
        <style name="foodRatingBar" parent="@android:style/Widget.RatingBar">
           <item name="android:progressDrawable">@drawable/food_rating_bar_full</item>
           <item name="android:minHeight">23dip</item>
           <item name="android:maxHeight">25dip</item>
       </style>
      </resources>
    

    food_rating_bar_full.xml

    This file must be in Drawable folder.

    <?xml version="1.0" encoding="utf-8"?>
    <layer-list xmlns:android="http://schemas.android.com/apk/res/android">
        <item android:id="@+id/background"
        android:drawable="@drawable/food_ratingbar_full_empty" />
        <item android:id="@+id/secondaryProgress"
        android:drawable="@drawable/food_ratingbar_full_empty" />
        <item android:id="@+id/progress"
        android:drawable="@drawable/food_ratingbar_full_filled" />
    </layer-list>
    

    food_ratingbar_full_empty.xml

    This file must be inside Drawable folder.

    <?xml version="1.0" encoding="utf-8"?>
    
    <!-- This is the rating bar drawable that is used to
     show a filled cookie. -->
    <selector
    xmlns:android="http://schemas.android.com/apk/res/android">
    
    <item android:state_pressed="true"
          android:state_window_focused="true"
          android:drawable="@drawable/cookiee" />
    
    <item android:state_focused="true"
          android:state_window_focused="true"
          android:drawable="@drawable/cookiee" />
    
    <item android:state_selected="true"
          android:state_window_focused="true"
          android:drawable="@drawable/cookiee" />
    
    <item android:drawable="@drawable/cookiee" />
    
    </selector>
    

    food_ratingbar_full_filled.xml

    This file must be located in Drawable folder.

    <?xml version="1.0" encoding="utf-8"?>
    
     <!-- This is the rating bar drawable that is used to
     show a unfilled cookie. -->
    <selector
    xmlns:android="http://schemas.android.com/apk/res/android">
    
    <item android:state_pressed="true"
          android:state_window_focused="true"
          android:drawable="@drawable/cookie" />
    
    <item android:state_focused="true"
          android:state_window_focused="true"
          android:drawable="@drawable/cookie" />
    
    <item android:state_selected="true"
          android:state_window_focused="true"
          android:drawable="@drawable/cookie" />
    
    <item android:drawable="@drawable/cookie" />
    
    </selector>
    

    main.xml file should look like :

    <?xml version="1.0" encoding="utf-8"?>
    <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
        android:orientation="vertical"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent">
    
        <RatingBar android:id="@+id/ratingBar1"
            style="@style/foodRatingBar"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content">
                
        </RatingBar>
    </LinearLayout>
    

    MainActivity.class should look like :

    import android.app.Activity;
    import android.os.Bundle;
    import android.widget.RatingBar;
    import android.widget.RatingBar.OnRatingBarChangeListener;
    import android.widget.Toast;
    
    public class MainActivity extends Activity {
    /** Called when the activity is first created. */
    
    RatingBar rb;
    
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);
        
        rb=(RatingBar)findViewById(R.id.ratingBar1);
        
        rb.setOnRatingBarChangeListener(new OnRatingBarChangeListener(){
    
            @Override
            public void onRatingChanged(RatingBar ratingBar, float rating,
                    boolean fromUser) {
                // TODO Auto-generated method stub
                    Toast.makeText(getApplicationContext(),Float.toString(rating),Toast.LENGTH_LONG).show();
                
            }
            
        }); 
    }
    }
    

    I have used two images:

    cookie.jpg

    cookiee.jpg

    This two images are of same size one is used for identifying selected Rating Bar and other for identifying unselected RatingBar

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

Sidebar

Related Questions

Hello all how can I create jar file of my project that is created
hello all, need to define a function that can be divided term by term
Hello all I hope someone can help me I am working on a simple
Hello all and thanks for your time reading this. I need to verify certificates
hello all i really need your help its my final project in university i
Hello all, I need to create a query for house search, that would match
Hello all I have a project where I need to perform single value bindings
Hello all and thanks for the help, I need to write every row from
Hello friends i need a book/ tutorials for rails without using scoffold. All the
I need to convert all of the following forms into .NET Uri object: hello.world

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.