{"id":1006,"date":"2016-02-22T06:05:38","date_gmt":"2016-02-22T06:05:38","guid":{"rendered":"http:\/\/abhiandroid.com\/ui\/?page_id=1006"},"modified":"2019-06-12T10:14:43","modified_gmt":"2019-06-12T10:14:43","slug":"ratingbar","status":"publish","type":"page","link":"https:\/\/abhiandroid.com\/ui\/ratingbar","title":{"rendered":"RatingBar Tutorial With Example In Android Studio"},"content":{"rendered":"<p>RatingBar is used to get the rating from the app user. A user can simply touch, drag or click on the stars to set the rating value. The value of rating always returns a floating point number\u00a0which\u00a0may be 1.0, 2.5, 4.5 etc.<\/p>\n<p><center><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-medium wp-image-1042\" src=\"\/ui\/wp-content\/uploads\/2016\/02\/RatingBar-in-Android-300x123.jpg\" alt=\"RatingBar in Android\" width=\"300\" height=\"123\" srcset=\"https:\/\/abhiandroid.com\/ui\/wp-content\/uploads\/2016\/02\/RatingBar-in-Android-300x123.jpg 300w, https:\/\/abhiandroid.com\/ui\/wp-content\/uploads\/2016\/02\/RatingBar-in-Android.jpg 454w\" sizes=\"auto, (max-width: 300px) 100vw, 300px\" \/><\/center>In Android, RatingBar is an extension of ProgressBar and SeekBar which\u00a0shows a rating in stars. RatingBar is a subclass of AbsSeekBar class.<\/p>\n<p>The\u00a0<code>getRating()<\/code>\u00a0method of android RatingBar class returns the rating number.<\/p>\n<p><strong>RatingBar code in XML:<\/strong><\/p>\n<pre>&lt;RatingBar\r\nandroid:id=\"@+id\/simpleRatingBar\"\r\nandroid:layout_width=\"wrap_content\"\r\nandroid:layout_height=\"wrap_content\" \/&gt;\r\n<\/pre>\n<hr \/>\n<h4><strong>Methods Used in Rating Bar:<\/strong><\/h4>\n<p><span style=\"color: #008000;\"><strong>getRating():<\/strong><\/span><\/p>\n<p>You can get the rating number from a RatingBar by using getRating() method. This method returns a Floating Point number. Below we get the current rating number from a RatingBar.<\/p>\n<pre>\/*Add in Oncreate() funtion after setContentView()*\/\r\nRatingBar simpleRatingBar = (RatingBar) findViewById(R.id.<em>simpleRatingBar<\/em>); \/\/ initiate a rating bar\r\nFloat ratingNumber = simpleRatingBar.getRating(); \/\/ get rating number from a rating bar\r\n<\/pre>\n<p><span style=\"color: #008000;\"><strong>getNumStars():<\/strong><\/span><\/p>\n<p>You can get the number of stars of a RatingBar by using getNumstars() method. This method returns int value. In below code\u00a0we get the total number of stars of a RatingBar.<\/p>\n<pre>\/*Add in Oncreate() funtion after setContentView()*\/\r\nRatingBar simpleRatingBar = (RatingBar) findViewById(R.id.<em>simpleRatingBar<\/em>); \/\/ initiate a rating bar\r\nint numberOfStars = simpleRatingBar.getNumStars(); \/\/ get total number of stars of rating bar\r\n<\/pre>\n<hr \/>\n<h4><strong>Attributes Used in\u00a0RatingBar:<\/strong><\/h4>\n<p>Now let\u2019s we discuss some important\u00a0attribute that helps us to configure a RatingBar in XML file (layout).<\/p>\n<p><strong><span style=\"color: #008000;\">1. id:<\/span>\u00a0<\/strong>id is an attribute used to uniquely identify a rating bar.<\/p>\n<pre>&lt;RatingBar\r\nandroid:id=\"@+id\/simpleRatingBar\"\r\nandroid:layout_width=\"wrap_content\"\r\nandroid:layout_height=\"wrap_content\"\/&gt;<\/pre>\n<p><span style=\"color: #008000;\"><strong>2. background:<\/strong><\/span>\u00a0background attribute is used to set the background of a RatingBar. We can set a color or a drawable in the background of a rating bar.<\/p>\n<p>Below we set the red color for the background of a rating bar.<\/p>\n<pre>&lt;RatingBar\r\n    android:id=\"@+id\/simpleRatingBar\"\r\n    android:layout_width=\"wrap_content\"\r\n    android:layout_height=\"wrap_content\"\r\n    android:background=\"#f00\"\/&gt; &lt;!-- red color for the background of rating bar--&gt;<\/pre>\n<p><center><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-1010\" src=\"\/ui\/wp-content\/uploads\/2016\/02\/BackGround-in-RatingBar.jpg\" alt=\"BackGround in RatingBar\" width=\"235\" height=\"204\" \/><\/center><strong>Setting Background of RatingBar In Java class:<\/strong><\/p>\n<pre>RatingBar simpleRatingBar = (RatingBar) findViewById(R.id.<em>simpleRatingBar<\/em>); \/\/ initiate a rating bar\r\nsimpleRatingBar.setBackgroundColor(Color.<em>RED<\/em>); \/\/ set background color for a rating bar\r\n<\/pre>\n<p><span style=\"color: #008000;\"><strong>3. numStars:<\/strong><\/span>\u00a0numStars attribute is used to set the number of stars (or rating items) to be displayed in a rating bar. By default a rating bar shows five stars but we can change it using numStars attribute.<\/p>\n<p>numStars must have\u00a0a integer number like 1,2 etc.<\/p>\n<p>Below we set num stars value to 7 of RatingBar.<\/p>\n<pre>&lt;RatingBar\r\n    android:id=\"@+id\/simpleRatingBar\"\r\n    android:layout_width=\"wrap_content\"\r\n    android:layout_height=\"wrap_content\"\r\n    android:numStars=\"7\" \/&gt;&lt;!-- number of stars to be displayed--&gt;<\/pre>\n<p><center><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-1011\" src=\"\/ui\/wp-content\/uploads\/2016\/02\/numStars-in-RatingBar-Android.jpg\" alt=\"numStars in RatingBar Android\" width=\"234\" height=\"185\" \/><\/center><strong>Setting numStars of RatingBar In Java class:<\/strong><\/p>\n<pre>RatingBar simpleRatingBar = (RatingBar) findViewById(R.id.<em>simpleRatingBar<\/em>); \/\/ initiate a rating bar\r\nsimpleRatingBar.setNumStars(7); \/\/ set total number of stars\r\n<\/pre>\n<p><span style=\"color: #008000;\"><strong>4. rating:<\/strong><\/span>\u00a0Rating attribute set the default rating of a rating bar. It must be a floating point number.<\/p>\n<p>Below we set default rating to 3.5 for a rating bar.<\/p>\n<pre>&lt;RatingBar\r\n    android:id=\"@+id\/simpleRatingBar\"\r\n    android:layout_width=\"wrap_content\"\r\n    android:layout_height=\"wrap_content\"\r\n    android:rating=\"3.5\" \/&gt; &lt;!-- default rating--&gt;<\/pre>\n<p><center><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-1012\" src=\"\/ui\/wp-content\/uploads\/2016\/02\/rating-in-RatingBar-Android.jpg\" alt=\"rating in RatingBar Android\" width=\"232\" height=\"194\" \/><\/center><strong>Setting Default Rating of RatingBar In Java class:<\/strong><\/p>\n<pre>\/*Add in Oncreate() funtion after setContentView()*\/\r\nRatingBar simpleRatingBar = (RatingBar) findViewById(R.id.<em>simpleRatingBar<\/em>); \/\/ initiate a rating bar\r\nsimpleRatingBar.setRating((float) 3.5); \/\/ set default rating<\/pre>\n<p><span style=\"color: #008000;\"><strong>5. padding:<\/strong><\/span>\u00a0padding attribute is used to set the padding from left, right, top or bottom.<\/p>\n<ul>\n<li><strong>paddingRight:<\/strong>\u00a0set padding from the right side of the rating bar<strong>.<\/strong><\/li>\n<li><strong>paddingLeft:<\/strong>\u00a0set padding from the left side of the rating bar<strong>.<\/strong><\/li>\n<li><strong>paddingTop:<\/strong>\u00a0set padding from the top side of the rating bar<strong>.<\/strong><\/li>\n<li><strong>paddingBottom:<\/strong>\u00a0set the padding from the bottom side of the rating bar<strong>.<\/strong><\/li>\n<li><strong>Padding:<\/strong>\u00a0set the padding from the all side\u2019s of the rating bar<strong>.<\/strong><\/li>\n<\/ul>\n<p>Below we set the 20dp padding from all the side\u2019s of the rating bar.<\/p>\n<pre>&lt;RatingBar\r\n    android:id=\"@+id\/simpleRatingBar\"\r\n    android:layout_width=\"wrap_content\"\r\n    android:layout_height=\"wrap_content\"\r\n    android:rating=\"2.5\"\r\n    android:numStars=\"6\"\r\n    android:background=\"#f00\"\r\n    android:padding=\"20dp\"\/&gt; &lt;!--20dp padding from all the sides of rating bar--&gt;<\/pre>\n<p><center><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-1013\" src=\"\/ui\/wp-content\/uploads\/2016\/02\/padding-in-RatingBar.jpg\" alt=\"padding in RatingBar\" width=\"233\" height=\"186\" \/><\/center><\/p>\n<hr \/>\n<h4><strong>RatingBar Example In Android Studio:<\/strong><\/h4>\n<p>Below is the example of RatingBar in Android\u00a0where\u00a0we displayed a RatingBar with five\u00a0stars and a submit button. Whenever a user click on the button value of total number of stars and value of rating is shown by using a Toast on screen. Below is the final output, download code and step by step tutorial:<\/p>\n<p style=\"text-align: center;\"><a class=\"download\" href=\"https:\/\/github.com\/abhisheksaini4\/RatingBarExample\" target=\"_blank\" rel=\"nofollow\">Download Code<\/a><a class=\"help\" title=\"Learn How To Download Code And Import In Android Studio\" href=\"\/androidstudio\/download-code-abhiandroid\" target=\"_blank\" rel=\"nofollow\"> ? <\/a><\/p>\n<p><center><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter wp-image-1014 size-full\" src=\"\/ui\/wp-content\/uploads\/2016\/02\/RatingBar-Example-in-Android-Studio.jpg\" alt=\"RatingBar Example in Android Studio\" width=\"218\" height=\"355\" srcset=\"https:\/\/abhiandroid.com\/ui\/wp-content\/uploads\/2016\/02\/RatingBar-Example-in-Android-Studio.jpg 218w, https:\/\/abhiandroid.com\/ui\/wp-content\/uploads\/2016\/02\/RatingBar-Example-in-Android-Studio-184x300.jpg 184w\" sizes=\"auto, (max-width: 218px) 100vw, 218px\" \/><\/center><span style=\"color: #ff0000;\"><strong>Important Note:<\/strong><\/span> We can also create custom rating bar in Android in which we can change the star images like\u00a0filled or\u00a0empty star. We discussed\u00a0this in next example, so don&#8217;t miss it.<\/p>\n<p><span style=\"color: #008000;\"><strong>Step 1:<\/strong><\/span> Create a new project and name it RatingBarExample<\/p>\n<pre>Select File -&gt; New -&gt; New Project and Fill the forms and click \"Finish\" button.\r\n<\/pre>\n<p><span style=\"color: #008000;\"><strong>Step 2:<\/strong><\/span> Open res -&gt; layout -&gt;\u00a0activity_main.xml (or) main.xml\u00a0and add following code<\/p>\n<p>In this step we open an xml file and add the code for displaying a rating bar with five\u00a0number of stars and \u201c2\u201d value for default rating and one submit button.<\/p>\n<pre>&lt;RelativeLayout xmlns:android=\"http:\/\/schemas.android.com\/apk\/res\/android\"\r\n    xmlns:tools=\"http:\/\/schemas.android.com\/tools\"\r\n    android:layout_width=\"match_parent\"\r\n    android:layout_height=\"match_parent\"\r\n    android:paddingBottom=\"@dimen\/activity_vertical_margin\"\r\n    android:paddingLeft=\"@dimen\/activity_horizontal_margin\"\r\n    android:paddingRight=\"@dimen\/activity_horizontal_margin\"\r\n    android:paddingTop=\"@dimen\/activity_vertical_margin\"\r\n    tools:context=\".MainActivity\"&gt;\r\n\r\n    &lt;RatingBar\r\n        android:id=\"@+id\/simpleRatingBar\"\r\n        android:layout_width=\"wrap_content\"\r\n        android:layout_height=\"wrap_content\"\r\n        android:layout_centerHorizontal=\"true\"\r\n        android:layout_marginTop=\"60dp\"\r\n        android:background=\"#0f0\"\r\n        android:paddingLeft=\"5dp\"\r\n        android:paddingRight=\"5dp\"\r\n        android:rating=\"2\" \/&gt;\r\n\r\n    &lt;Button\r\n        android:id=\"@+id\/submitButton\"\r\n        android:layout_width=\"200dp\"\r\n        android:layout_height=\"wrap_content\"\r\n        android:layout_centerInParent=\"true\"\r\n        android:background=\"#f00\"\r\n        android:padding=\"10dp\"\r\n        android:text=\"Submit\"\r\n        android:textColor=\"#fff\"\r\n        android:textSize=\"20sp\"\r\n        android:textStyle=\"bold\" \/&gt;\r\n&lt;\/RelativeLayout&gt;<\/pre>\n<p><span style=\"color: #008000;\"><strong>Step 3:<\/strong><\/span> Open src -&gt; package -&gt;\u00a0<strong>MainActivity.<\/strong><strong>java<\/strong><\/p>\n<p>In this step we open\u00a0MainActivity\u00a0where\u00a0we add the code to\u00a0initiate the RatingBar &amp;\u00a0button and then we perform click event on button and display the total number of stars and rating by using a toast.<\/p>\n<pre>package example.gb.ratingbarexample;\r\n\r\nimport android.support.v7.app.AppCompatActivity;\r\nimport android.os.Bundle;\r\nimport android.view.Menu;\r\nimport android.view.MenuItem;\r\nimport android.view.View;\r\nimport android.widget.RatingBar;\r\nimport android.widget.Button;\r\nimport android.widget.Toast;\r\n\r\npublic class MainActivity extends AppCompatActivity {\r\n\r\n    @Override\r\n    protected void onCreate(Bundle savedInstanceState) {\r\n        super.onCreate(savedInstanceState);\r\n        setContentView(R.layout.activity_main);\r\n        \/\/ initiate rating bar and a button\r\n        final RatingBar simpleRatingBar = (RatingBar) findViewById(R.id.simpleRatingBar);\r\n        Button submitButton = (Button) findViewById(R.id.submitButton);\r\n        \/\/ perform click event on button\r\n        submitButton.setOnClickListener(new View.OnClickListener() {\r\n            @Override\r\n            public void onClick(View v) {\r\n                \/\/ get values and then displayed in a toast\r\n                String totalStars = \"Total Stars:: \" + simpleRatingBar.getNumStars();\r\n                String rating = \"Rating :: \" + simpleRatingBar.getRating();\r\n                Toast.makeText(getApplicationContext(), totalStars + \"\\n\" + rating, Toast.LENGTH_LONG).show();\r\n            }\r\n        });\r\n    }\r\n\r\n\r\n}<\/pre>\n<p><span style=\"color: #008000;\"><strong>Output:<\/strong><\/span><\/p>\n<p>Now start the AVD in Emulator and run the App. You will see the rating option on screen.\u00a0Select your rating and click on Submit. Your rating will be displayed on screen as Toast.<\/p>\n<p><center><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-medium wp-image-1014\" src=\"\/ui\/wp-content\/uploads\/2016\/02\/RatingBar-Example-in-Android-Studio-184x300.jpg\" alt=\"RatingBar Example Output\" width=\"184\" height=\"300\" srcset=\"https:\/\/abhiandroid.com\/ui\/wp-content\/uploads\/2016\/02\/RatingBar-Example-in-Android-Studio-184x300.jpg 184w, https:\/\/abhiandroid.com\/ui\/wp-content\/uploads\/2016\/02\/RatingBar-Example-in-Android-Studio.jpg 218w\" sizes=\"auto, (max-width: 184px) 100vw, 184px\" \/><\/center><\/p>\n<hr \/>\n<h4><strong>Custom RatingBar Example In Android Studio:<\/strong><\/h4>\n<p>In the below example of custom rating bar in Android, we displayed a rating bar with five <strong>custom\u00a0stars<\/strong> and a submit button. Whenever a user click on the button value of total number of stars and value of rating is shown by using a Toast. Below is the final output, download code and step by step explanation of Custom RatingBar.<\/p>\n<p style=\"text-align: center;\"><a class=\"download\" href=\"https:\/\/github.com\/abhisheksaini4\/CustomRatingBarExample\" target=\"_blank\" rel=\"nofollow\">Download Code<\/a><a class=\"help\" title=\"Learn How To Download Code And Import In Android Studio\" href=\"\/androidstudio\/download-code-abhiandroid\" target=\"_blank\" rel=\"nofollow\"> ? <\/a><\/p>\n<p><center><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-1015\" src=\"\/ui\/wp-content\/uploads\/2016\/02\/Custom-RatingBar-Example-in-Android-Studio.jpg\" alt=\"Custom RatingBar Example in Android Studio\" width=\"207\" height=\"365\" srcset=\"https:\/\/abhiandroid.com\/ui\/wp-content\/uploads\/2016\/02\/Custom-RatingBar-Example-in-Android-Studio.jpg 207w, https:\/\/abhiandroid.com\/ui\/wp-content\/uploads\/2016\/02\/Custom-RatingBar-Example-in-Android-Studio-170x300.jpg 170w\" sizes=\"auto, (max-width: 207px) 100vw, 207px\" \/><\/center><span style=\"color: #008000;\"><strong>Step 1:<\/strong><\/span> Create a new project and name it CustomRatingBarExample<\/p>\n<pre>Select File -&gt; New -&gt; New Project -&gt; then Fill the forms and click \"Finish\" button.\r\n<\/pre>\n<p><span style=\"color: #008000;\"><strong>Step 2:<\/strong><\/span> Open res -&gt; layout -&gt; activity_main.xml (or) main.xml\u00a0and add following code<\/p>\n<p>In this step we open an xml file and add the code for displaying a custom rating bar with five\u00a0number of stars and \u201c 2.5 \u201d value for default rating and one submit button.<\/p>\n<pre>&lt;RelativeLayout xmlns:android=\"http:\/\/schemas.android.com\/apk\/res\/android\"\r\n    xmlns:tools=\"http:\/\/schemas.android.com\/tools\"\r\n    android:layout_width=\"match_parent\"\r\n    android:layout_height=\"match_parent\"\r\n    android:background=\"#fff\"\r\n    android:paddingBottom=\"@dimen\/activity_vertical_margin\"\r\n    android:paddingLeft=\"@dimen\/activity_horizontal_margin\"\r\n    android:paddingRight=\"@dimen\/activity_horizontal_margin\"\r\n    android:paddingTop=\"@dimen\/activity_vertical_margin\"\r\n    tools:context=\".MainActivity\"&gt;\r\n\r\n    &lt;RatingBar\r\n        android:id=\"@+id\/simpleRatingBar\"\r\n        style=\"@style\/customRatingBar\"\r\n        android:layout_width=\"wrap_content\"\r\n        android:layout_height=\"60dp\"\r\n        android:layout_centerHorizontal=\"true\"\r\n        android:layout_marginTop=\"60dp\"\r\n        android:background=\"#0f0\"\r\n        android:rating=\"2.5\" \/&gt;\r\n\r\n    &lt;Button\r\n        android:id=\"@+id\/submitButton\"\r\n        android:layout_width=\"200dp\"\r\n        android:layout_height=\"wrap_content\"\r\n        android:layout_centerInParent=\"true\"\r\n        android:background=\"#f40\"\r\n        android:padding=\"10dp\"\r\n        android:text=\"Submit\"\r\n        android:textColor=\"#fff\"\r\n        android:textSize=\"20sp\"\r\n        android:textStyle=\"bold\" \/&gt;\r\n&lt;\/RelativeLayout&gt;<\/pre>\n<p><span style=\"color: #008000;\"><strong>Step 3:<\/strong><\/span> Open src -&gt; package -&gt;\u00a0<strong>MainActivity.<\/strong><strong>java<\/strong><\/p>\n<p>In this step we open\u00a0MainActivity\u00a0where\u00a0we add the code to\u00a0initiate the RatingBar &amp;\u00a0button and then perform click event on button and display the total number of stars and rating by using a Toast.<\/p>\n<pre>package example.gb.customratingbarexample;\r\n\r\nimport android.support.v7.app.AppCompatActivity;\r\nimport android.os.Bundle;\r\nimport android.view.Menu;\r\nimport android.view.MenuItem;\r\nimport android.view.View;\r\nimport android.widget.RatingBar;\r\nimport android.widget.Button;\r\nimport android.widget.Toast;\r\n\r\npublic class MainActivity extends AppCompatActivity {\r\n\r\n    @Override\r\n    protected void onCreate(Bundle savedInstanceState) {\r\n        super.onCreate(savedInstanceState);\r\n        setContentView(R.layout.activity_main);\r\n        \/\/ initiate rating bar and a button\r\n        final RatingBar simpleRatingBar = (RatingBar) findViewById(R.id.simpleRatingBar);\r\n        Button submitButton = (Button) findViewById(R.id.submitButton);\r\n        \/\/ perform click event on button\r\n        submitButton.setOnClickListener(new View.OnClickListener() {\r\n            @Override\r\n            public void onClick(View v) {\r\n                \/\/ get values and then displayed in a toast\r\n                String totalStars = \"Total Stars:: \" + simpleRatingBar.getNumStars();\r\n                String rating = \"Rating :: \" + simpleRatingBar.getRating();\r\n                Toast.makeText(getApplicationContext(), totalStars + \"\\n\" + rating, Toast.LENGTH_LONG).show();\r\n            }\r\n        });\r\n    }\r\n    \r\n}<\/pre>\n<p><span style=\"color: #008000;\"><strong>Step 4:<\/strong><\/span>\u00a0Open res -&gt;values -&gt;<strong>styles<\/strong><strong>.xml<\/strong><\/p>\n<p>In this step we add the code for displaying custom stars for rating. To do that in this styles.xml file we set an custom xml file\u00a0from drawable and set the height and width for that\u00a0item.<\/p>\n<pre>&lt;resources&gt;\r\n\r\n    &lt;!-- Base application theme. --&gt;\r\n    &lt;style name=\"AppTheme\" parent=\"Theme.AppCompat.Light.DarkActionBar\"&gt;\r\n        &lt;!-- Customize your theme here. --&gt;\r\n    &lt;\/style&gt;\r\n    &lt;style name=\"customRatingBar\" parent=\"@android:style\/Widget.RatingBar\"&gt;\r\n        &lt;item name=\"android:progressDrawable\"&gt;@drawable\/customratingstars&lt;\/item&gt;\r\n        &lt;item name=\"android:minHeight\"&gt;20dip&lt;\/item&gt;\r\n        &lt;item name=\"android:maxHeight\"&gt;20dip&lt;\/item&gt;\r\n    &lt;\/style&gt;\r\n&lt;\/resources&gt;<\/pre>\n<p><strong><span style=\"color: #008000;\">Step 5:<\/span>\u00a0<\/strong>Create a new drawable XML\u00a0file &#8211;&gt;<strong> customratingstars.xml<\/strong><\/p>\n<p>In this step we create a new drawable XML\u00a0file, in which we set the icons for filled and empty stars. As shown in below code snippet empty and filled are two different icons set from drawable.<\/p>\n<pre>&lt;?xml version=\"1.0\" encoding=\"utf-8\"?&gt;\r\n&lt;layer-list xmlns:android=\"http:\/\/schemas.android.com\/apk\/res\/android\"&gt;\r\n    &lt;item android:id=\"@android:id\/background\"\r\n        android:drawable=\"@drawable\/empty\" \/&gt;\r\n    &lt;item android:id=\"@android:id\/secondaryProgress\"\r\n        android:drawable=\"@drawable\/empty\" \/&gt;\r\n    &lt;item android:id=\"@android:id\/progress\"\r\n        android:drawable=\"@drawable\/filled\" \/&gt;\r\n&lt;\/layer-list&gt;<strong>\u00a0<\/strong><\/pre>\n<p><span style=\"color: #008000;\"><strong>Output:<\/strong><\/span><\/p>\n<p>Now start the AVD in Emulator and run the App. You will see custom star\u00a0rating option on screen.<\/p>\n<p><center><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-medium wp-image-1015\" src=\"\/ui\/wp-content\/uploads\/2016\/02\/Custom-RatingBar-Example-in-Android-Studio-170x300.jpg\" alt=\"Custom RatingBar Example in Android Studio\" width=\"170\" height=\"300\" srcset=\"https:\/\/abhiandroid.com\/ui\/wp-content\/uploads\/2016\/02\/Custom-RatingBar-Example-in-Android-Studio-170x300.jpg 170w, https:\/\/abhiandroid.com\/ui\/wp-content\/uploads\/2016\/02\/Custom-RatingBar-Example-in-Android-Studio.jpg 207w\" sizes=\"auto, (max-width: 170px) 100vw, 170px\" \/><\/center><\/p>\n","protected":false},"excerpt":{"rendered":"<p>RatingBar is used to get the rating from the app user. A user can simply touch, drag or click on the stars to set the rating value. The value of rating always returns a floating point number\u00a0which\u00a0may be 1.0, 2.5, 4.5 etc. In Android, RatingBar is an extension of ProgressBar and SeekBar which\u00a0shows a rating &hellip; <a href=\"https:\/\/abhiandroid.com\/ui\/ratingbar\" class=\"more-link\">Continue reading <span class=\"screen-reader-text\">RatingBar Tutorial With Example In Android Studio<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"parent":0,"menu_order":0,"comment_status":"open","ping_status":"closed","template":"home.php","meta":{"_acf_changed":false,"footnotes":""},"class_list":["post-1006","page","type-page","status-publish","hentry"],"acf":[],"psp_head":"<title>RatingBar Tutorial With Example In Android Studio \u2013 Abhi Android<\/title>\r\n<meta name=\"description\" content=\"RatingBar is used to get the rating from the app user. Learn how we can create custom RatingBar in Android with example in Android Studio.\" \/>\r\n<meta name=\"robots\" content=\"index,follow\" \/>\r\n<link rel=\"canonical\" href=\"https:\/\/abhiandroid.com\/ui\/ratingbar\" \/>\r\n","_links":{"self":[{"href":"https:\/\/abhiandroid.com\/ui\/wp-json\/wp\/v2\/pages\/1006","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/abhiandroid.com\/ui\/wp-json\/wp\/v2\/pages"}],"about":[{"href":"https:\/\/abhiandroid.com\/ui\/wp-json\/wp\/v2\/types\/page"}],"author":[{"embeddable":true,"href":"https:\/\/abhiandroid.com\/ui\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/abhiandroid.com\/ui\/wp-json\/wp\/v2\/comments?post=1006"}],"version-history":[{"count":3,"href":"https:\/\/abhiandroid.com\/ui\/wp-json\/wp\/v2\/pages\/1006\/revisions"}],"predecessor-version":[{"id":2795,"href":"https:\/\/abhiandroid.com\/ui\/wp-json\/wp\/v2\/pages\/1006\/revisions\/2795"}],"wp:attachment":[{"href":"https:\/\/abhiandroid.com\/ui\/wp-json\/wp\/v2\/media?parent=1006"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}