Introduction
Android RatingBar can be used to get a rating from the user. The Rating returns a floating-point number. It may be 2.0, 3.5, 4.0 etc. Android RatingBar displays the rating in stars. In this article, I will show you how to create a RatingBar Android App using Android Studio.
Requirements
- Android Studio version 2.3.3
- Little bit XML and JAVA knowledge.
- Android Emulator (or) Android mobile
- Download link (Android Studio)
Important Points to Remember
The getRating() method of the Android RatingBar class returns the rating number.
Create a New Project
Open Android Studio and create a New Android Studio Project.

activity_main.xml
Drag the RatingBar and Button from the palette now the activity_main.xml file will look like this,
- <RelativeLayout
- xmlns:android="http://schemas.android.com/apk/res/android"
- xmlns:tools="http://schemas.android.com/tools"
- android:layout_width="match_parent"
- android:layout_height="match_parent"
- tools:context=".MainActivity" >
- <RatingBar
- android:id="@+id/ratingBar1"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:layout_alignParentTop="true"
- android:layout_centerHorizontal="true"
- android:layout_marginTop="44dp" />
- <Button
- android:id="@+id/button1"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:layout_alignLeft="@+id/ratingBar1"
- android:layout_below="@+id/ratingBar1"
- android:layout_marginLeft="92dp"
- android:layout_marginTop="66dp"
- android:text="submit" />
- </RelativeLayout>

Activity class
Let's write the code to display the rating of the user.
MainActivity.java- The Header File







Join the conversation! Your thoughts help the community grow.