#RatingBar #AndroidStudio #starRating
Star 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 which may be 1.0, 2.5, 4.5 etc.
In Android, RatingBar is an extension of ProgressBar and SeekBar which shows a rating in stars. RatingBar is a subclass of AbsSeekBar class.
The getRating() method of android RatingBar class returns the rating number.
getRating():
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.
getNumStars():
You can get the number of stars of a RatingBar by using getNumstars() method. This method returns int value. In below code we get the total number of stars of a RatingBar.
Now let’s we discuss some important attribute that helps us to configure a RatingBar in XML file (layout).
1. id: id is an attribute used to uniquely identify a rating bar.
2. background: background 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.
Below we set the red color for the background of a rating bar.
3. numStars: numStars 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.
numStars must have a integer number like 1,2 etc.
Below we set num stars value to 7 of RatingBar
4. rating: Rating attribute set the default rating of a rating bar. It must be a floating point number.
Below we set default rating to 3.5 for a rating bar
5. padding: padding attribute is used to set the padding from left, right, top or bottom.
paddingRight: set padding from the right side of the rating bar.
paddingLeft: set padding from the left side of the rating bar.
paddingTop: set padding from the top side of the rating bar.
paddingBottom: set the padding from the bottom side of the rating bar.
Padding: set the padding from the all side’s of the rating bar.
Below we set the 20dp padding from all the side’s of the rating bar.
👩💻👨💻Android Course
1. Text View
2. Button
3. Edit Text
4. Radio Button & Radio group
5. Check box
6. Switch
7. Toggle Button
8. Rating Bar
9. Seek Bar
10. Progress Bar
11. Spinner
12. Time picker
13. Date Picker
14. Simple and Custom Toast
15. Alert Dialog
Menu Bars
1. Action Bar
2. Option Menu
3. Context Menu
4. Popup Menu
Intents
1. Explicit intents
2. Implicit Intents
3. Share
4. Call
5. Message
Advanced
1. Splash Screen
2. List View
3. Grid View
4. Tab View
5. Video View
6. Audio View
7. Image slider
8. Send SMS
9. Send Email
10. Send Call
11. Blue Tooth
12. Map Navigation
13. Text Switcher
14. Image Switcher
15. Stack View
16. Bottom Sheet
17. Navigation Drawer
18. Notification
19. Tab View
20. Sql Lite Database
Ecommerce App Project
#xml file,
design layout designing,
#E-commerce Application development
#Cooking application designing
#poetry Application development
#university Management App
Android app development full course:
• Introduction to android app development #1...
Freelancing complete course:
• Create first gig on Fiverr part1 || Full c...
Flutter Mobile app development course:
• Flutter introduction for Mobile developmen...
👩💻Android Apps with source code:
• eCommerce App development With source co...