3

I would like to customise the title, description and button font sizes for the material alert dialog made using MaterialAlertDialogBuilder using a custom style from the styles.xml file. However, I am not sure how to go about creating the style. Can someone please help me out with that. TIA

speedster01
  • 433
  • 3
  • 19
  • possible duplicate of https://stackoverflow.com/questions/6562924/changing-font-size-into-an-alertdialog – coroutineDispatcher Apr 22 '19 at 12:15
  • 1
    The link you have given does not use material theme. My dialog uses material theme and hence not the same classes. I tried the solutions given for dialogs without material theming, but they did not work. – speedster01 Apr 22 '19 at 12:49

1 Answers1

1
AlertDialog dialog = new MaterialAlertDialogBuilder(this)
                .setMessage(description)
                .setCancelable(false)
                .setPositiveButton(R.string.ok, null)
                .create();

        dialog.show();

        dialog.getButton(Dialog.BUTTON_POSITIVE).setTextSize(18);

        TextView textView = dialog.findViewById(android.R.id.message);
        if (textView != null) {
            textView.setTextSize(18);
        }
Hadi Ahmadi
  • 1,924
  • 2
  • 17
  • 38