Android dialog with icon in subtitle

Viewed 46

I am trying to use android dialog , with icon set to subtitle. I am using the below code, but getting icon in title. I am trying to get something like the attached image. enter image description here

dialogBox = new MaterialAlertDialogBuilder(dialogContext)
                        .setTitle("Power Off")// getting image in title
                        .setMessage("Shutting Down")// Need image here
                        .setIcon(R.mipmap.loader)
                        .setCancelable(false)
                        .show();
1 Answers

Pls try with following code.


dialogBox = new MaterialAlertDialogBuilder(dialogContext)
                        .setTitle("Power Off")// getting image in title
                        .setMessage("Shutting Down")// Need image here
                        .setIcon(dialogContext.getResources().getDrawable(R.mipmap.loader))
                        .setCancelable(false)
                        .show();
Related