How to make builder.setPositiveButton and builder.setNegativeButtons bigger in alertDialog?

Viewed 1932

I set a "Do you want to Log Out" question and then a YES or NO as a builder.setPositiveButton and builder.setNegativeButton. However, the YES and NO words are too small. How do I make them bigger? Here's what I have in my NavigationDrawer when "Log Out" item clicked and alertDialog pops up:

enter image description here

Here's the code for alertDialog:

    AlertDialog.Builder builder = new   AlertDialog.Builder(MainActivity.this);

         builder.setCancelable(false); 

         builder.setTitle("Are you sure you want to Log Out?");

         builder.setNegativeButton("NO", new DialogInterface.OnClickListener() {

        public void onClick(DialogInterface dialog, int WhichButton)  {
         dialog.cancel();
         }
         });
       builder.setPositiveButton("YES", new DialogInterface.OnClickListener() {
        public void onClick(DialogInterface dialog, int which) {
          }
           });

           builder.show();

So i'm just looking to make the words "YES" and "NO" bigger, how do I do it?

1 Answers

You can style the defalut AlertDialog or you can make your own Custom layout xml file for it.

1) For styling:

<?xml version="1.0" encoding="utf-8"?>
<resources>
    <style name="AlertDialogCustom" parent="@android:style/Theme.Dialog">
        <item name="android:textColor">#00FF00</item>
        <item name="android:typeface">monospace</item>
        <item name="android:textSize">10sp</item>
    </style>
</resources>

2) For custom dialog :

AlertDialog.Builder dialogBuilder = new AlertDialog.Builder(this);
LayoutInflater inflater = this.getLayoutInflater();
View dialogView = inflater.inflate(R.layout.alert_label_editor, null);
dialogBuilder.setView(dialogView);

EditText editText = (EditText) dialogView.findViewById(R.id.label_field);
editText.setText("test label");
AlertDialog alertDialog = dialogBuilder.create();
alertDialog.show();

Where R.layout.alert_label_editor is your own custom layout file.

Related