Android Jetpack Compose - Implement Easy Rating Dialog
Last Updated :
28 Apr, 2025
Many times in android applications we can get to see that they ask for users to rate their application and share their reviews about the application. In this article, we will take a look at How to implement an Easy Rating dialog in android applications using Jetpack Compose. Using the Easy Rating Dialog box we will display a prompt to the user to rate the application. A sample video is given below to get an idea about what we are going to do in this article.
Step by Step Implementation
Step 1: Create a New Project in Android Studio
To create a new project in Android Studio please refer to How to Create/Start a New Project in Android Studio. While choosing the template, select Empty Compose Activity. If you do not find this template, try upgrading the Android Studio to the latest version. We demonstrated the application in Kotlin, so make sure you select Kotlin as the primary language while creating a New Project.
Step 2: Adding dependency in build.gradle
Navigate to app>build.gradle file and add the below dependency to it in the dependencies section.
implementation 'com.github.fernandodev.easyratingdialog:easyratingdialog:1.1.2'
After adding the dependency simply sync your project to install it.
Step 3: Working with the MainActivity.kt file
Go to the MainActivity.kt file and refer to the following code. Below is the code for the MainActivity.kt file. Comments are added inside the code to understand the code in more detail.
Kotlin
package com.example.newcanaryproject
import android.app.Activity
import android.content.Context
import android.os.Bundle
import android.webkit.WebSettings.TextSize
import androidx.activity.ComponentActivity
import androidx.activity.compose.setContent
import androidx.compose.foundation.background
import androidx.compose.foundation.layout.*
import androidx.compose.material.*
import androidx.compose.runtime.Composable
import androidx.compose.ui.Modifier
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.platform.LocalContext
import androidx.compose.ui.text.font.FontWeight
import androidx.compose.ui.text.style.TextAlign
import androidx.compose.ui.unit.dp
import androidx.compose.ui.unit.sp
import androidx.core.content.ContextCompat
import com.example.newcanaryproject.ui.theme.NewCanaryProjectTheme
import com.example.newcanaryproject.ui.theme.greenColor
import com.github.fernandodev.easyratingdialog.library.EasyRatingDialog
class MainActivity : ComponentActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContent {
NewCanaryProjectTheme {
// on below line we are specifying
// background color for our application
Surface(
// on below line we are specifying
// modifier and color for our app
modifier = Modifier.fillMaxSize(), color = MaterialTheme.colors.background
) {
// on the below line we are specifying
// the theme as the scaffold.
Scaffold(
// in scaffold we are
// specifying the top bar.
topBar = {
// inside top bar we are specifying
// background color.
TopAppBar(backgroundColor = greenColor,
// along with that we are specifying
// title for our top bar.
title = {
// in the top bar we are
// specifying tile as a text
Text(
// on below line we are specifying
// text to display in top app bar.
text = "GFG",
// on below line we are specifying
// modifier to fill max width.
modifier = Modifier.fillMaxWidth(),
// on below line we are specifying
// text alignment.
textAlign = TextAlign.Center,
// on below line we are specifying
// color for our text.
color = Color.White
)
})
}) {
// on below line we are calling
// method to display UI
ratingDialog(LocalContext.current)
}
}
}
}
}
}
@Composable
fun ratingDialog(context: Context) {
// on below line creating variable for rating dialog.
var easyRatingDialog = EasyRatingDialog(context);
Column(
modifier = Modifier
.fillMaxHeight()
.fillMaxWidth()
.background(Color.White)
) {
// on below line we are adding a spacer.
Spacer(modifier = Modifier.height(120.dp))
// on below line we are adding a text
Text(
// on below line specifying text for heading.
text = "Rate Us Dialog in Android",
// adding text alignment,
textAlign = TextAlign.Center,
// on below line adding text color.
color = greenColor,
// on below line adding font weight.
fontWeight = FontWeight.Bold,
// on below line adding padding from all sides.
modifier = Modifier
.padding(10.dp)
.fillMaxWidth()
)
// on below line adding a spacer.
Spacer(modifier = Modifier.height(50.dp))
// on below line adding a button to
// display an alerter dialog.
Button(
onClick = {
// on below line creating an alerter.
easyRatingDialog.showAnyway()
},
// on below line adding modifier for button.
modifier = Modifier
.fillMaxWidth()
.padding(20.dp)
) {
// on below line displaying text for our button.
Text(text = "Display Rate Me Dialog", color = Color.White)
}
}
}
Now run your application to see the output of it.
Output:
Similar Reads
Android Jetpack Compose - Implement Navigation Drawer Jetpack Compose is a new UI toolkit from Google used to create native Android UI. It speeds up and simplifies UI development using less code, Kotlin APIs, and powerful tools.PrerequisitesFamiliar with Kotlin and OOP ConceptsBasic understanding of Jetpack ComposeThe navigation drawer is the most used
3 min read
Android Jetpack Compose - Implement Dark Mode Jetpack Compose is a new UI toolkit from Google that is used to create native Android UI. It speeds up and simplifies UI development by using less code, Kotlin APIs, and powerful tools.Fortunately, Android 10 and later enable automatically "dark-theming" your app by forcing it to utilize certain dar
3 min read
Date Picker in Android using Jetpack Compose In Android, a Date Picker is a widget used to select a date from the calendar. When a Date Picker is implemented in an application, the user can select a year, a month, and a day, combining to form date from a calendar-like-looking box. This data is generally needed and collected in applications tha
2 min read
Android - Open Dialer Through Intent using Jetpack Compose The phone dialer is an activity in the android application that is used to make a phone call within the android device. The dialer activity is used to dial a phone number and make a call. In this article, we will take a look at How to open a dialer in the android application through Intent in our an
5 min read
Expandable Text in Android using Jetpack Compose Many applications display tons of textual data in the form of passages and have the feature of expanding or contracting it. Generally, 2-3 out of n lines of a passage are displayed along with "View More", "Read More", and "..." at the end. These appear like hyperlinks that upon click expand the text
2 min read