How to create android alertdialog custom layout message ? - SpartaCode


Make your development faster and easier !

How to create android alertdialog custom layout message ?

To make your app beautiful and standard we need to provide messages in extra ordinary way instead of using any kind of toast messages which are quite usual.

So im here with simple util file which will create dialogs in just 2 lines.

Note: Copy this file into your Android project.

Copy this into your colors.xml file in values :

<color name="warning">#ffbaba</color>
<color name="error">#d8000c</color>
<color name="success">#dff2bf</color>

Step 1: Download supporting layout file

Note: Copy this file into your layout package in res folder.

Step 2: Use Message dialog in your Activity

MessageDialog messagedialog=new MessageDialog(MainActivity.this);
messagedialog.showMessageDialog("Hello this is beautiful message dialog","Success");

Add this to your style.xml :

 <style name="PauseDialogAnimation">
        <item name="android:windowEnterAnimation">@anim/push_right_in</item>
        <item name="android:windowExitAnimation">@android:anim/slide_out_right</item>


Syntax :
showMessageDialog(<Message> , <Type>);

<Type>  : "Success" OR "Warning"

Note : You may have some errors in file which will be missing resource files.
You can replace it with your image drawables.

Thank You
Like and Subscribe


  1. Nice tutorial... Thanks!!! I have implemented this in my app and it has made my app look more pleasant

  2. I have read your article, it is very informative and helpful for me.I admire the valuable information you offer in your articles. Thanks for posting it..
    mac task management app