Skip to content
Related Articles
Get the best out of our app
GeeksforGeeks App
Open App

Related Articles

How to Create a Full Screen AlertDialog in Android?

Improve Article
Save Article
Like Article
Improve Article
Save Article
Like Article

AlertDialog in Android is an alert message programmatically displayed to the user over the change of course of action. This appears as a pop-up and has four elements i.e., a title, a message, a positive button, and a negative button. Typically, AlertDialog is non-customized and appears as overlaying box in the center of the screen. However, we can customize it completely.

So in this article, we will show you how you could make a Full-Screen AlertDialog in Android. Follow the below steps once the IDE is ready.

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. We demonstrated the application in Kotlin, so make sure you select Kotlin as the primary language while creating a New Project.

Step 2: Working with the activity_main.xml file

Navigate to the app > res > layout > activity_main.xml and add the below code to that file. Below is the code for the activity_main.xml file. Add a button that on click will generate an AlertDialog.


<?xml version="1.0" encoding="utf-8"?>

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.


package org.geeksforgeeks.fullscreendialog
import android.os.Bundle
import android.widget.Button
class MainActivity : AppCompatActivity() {
    override fun onCreate(savedInstanceState: Bundle?) {
        // Declare and Initialize 
        // the Button from the layout file
        val mButton = findViewById<Button>(
        // When button is clicked
        mButton.setOnClickListener {
            // Declaring and initializing a Builder 
            // for the Alert Dialog with a FullScreen theme
            val mBuilder = AlertDialog.Builder(this,
                .setPositiveButton("Positive", null)
                .setNegativeButton("Negative", null)
            // Create the AlertDialog
            val mAlertDialog = mBuilder.create()
            // Show the AlertDialog


You can see that the AlertDialog is displaying on full screen.

My Personal Notes arrow_drop_up
Last Updated : 30 Jan, 2022
Like Article
Save Article
Similar Reads