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
Decorators in Python In Python, decorators are a powerful and flexible way to modify or extend the behavior of functions or methods, without changing their actual code. A decorator is essentially a function that takes another function as an argument and returns a new function with enhanced functionality. Decorators are
10 min read
AVL Tree Data Structure An AVL tree defined as a self-balancing Binary Search Tree (BST) where the difference between heights of left and right subtrees for any node cannot be more than one. The absolute difference between the heights of the left subtree and the right subtree for any node is known as the balance factor of
4 min read
Sliding Window Technique Sliding Window Technique is a method used to solve problems that involve subarray or substring or window. The main idea is to use the results of previous window to do computations for the next window. This technique is commonly used in algorithms like finding subarrays with a specific sum, finding t
13 min read
What is a Neural Network? Neural networks are machine learning models that mimic the complex functions of the human brain. These models consist of interconnected nodes or neurons that process data, learn patterns, and enable tasks such as pattern recognition and decision-making.In this article, we will explore the fundamenta
14 min read
ArrayList in Java Java ArrayList is a part of the collections framework and it is a class of java.util package. It provides us with dynamic-sized arrays in Java. The main advantage of ArrayList is that, unlike normal arrays, we don't need to mention the size when creating ArrayList. It automatically adjusts its capac
9 min read
Read JSON file using Python The full form of JSON is JavaScript Object Notation. It means that a script (executable) file which is made of text in a programming language, is used to store and transfer the data. Python supports JSON through a built-in package called JSON. To use this feature, we import the JSON package in Pytho
4 min read
Multithreading in Python This article covers the basics of multithreading in Python programming language. Just like multiprocessing , multithreading is a way of achieving multitasking. In multithreading, the concept of threads is used. Let us first understand the concept of thread in computer architecture. What is a Process
8 min read
Two Pointers Technique Two pointers is really an easy and effective technique that is typically used for Two Sum in Sorted Arrays, Closest Two Sum, Three Sum, Four Sum, Trapping Rain Water and many other popular interview questions. Given a sorted array arr (sorted in ascending order) and a target, find if there exists an
11 min read
Python Match Case Statement Introduced in Python 3.10, the match case statement offers a powerful mechanism for pattern matching in Python. It allows us to perform more expressive and readable conditional checks. Unlike traditional if-elif-else chains, which can become unwieldy with complex conditions, the match-case statement
7 min read
Architecture of 8085 microprocessor A microprocessor is fabricated on a single integrated circuit (IC) or chip that is used as a central processing unit (CPU).The 8085 microprocessor is an 8-bit microprocessor that was developed by Intel in the mid-1970s. It was widely used in the early days of personal computing and was a popular cho
11 min read