Skip to content Skip to sidebar Skip to footer

Size Of Button In Alertdialog

how can i change the size of button in alertdailog in code without using xml ? I'm not using view .. Thank you The code : alertbox3.setNeutralButton('Cancel',new DialogInterface

Solution 1:

you may try this code:

 AlertDialog.Builderadb=newAlertDialog.Builder(this);
 Dialogd= adb.setView(newView(this)).create();
// (That new View is just there to have something inside the dialog that can grow big enough to cover the whole screen.)

WindowManager.LayoutParamslp=newWindowManager.LayoutParams();
lp.copyFrom(d.getWindow().getAttributes());
lp.width = WindowManager.LayoutParams.FILL_PARENT;
lp.height = WindowManager.LayoutParams.FILL_PARENT;
d.show();
d.getWindow().setAttributes(lp);

and http://developer.android.com/reference/android/widget/Button.html

look at this link aslo . Link1 and LInk2

Solution 2:

Solution 3:

Try this : https://stackoverflow.com/a/15910202/305135

finalAlertDialogalert= builder.create();
alert.setOnShowListener(newDialogInterface.OnShowListener() {
    @OverridepublicvoidonShow(DialogInterface dialog) {
        ButtonbtnPositive= alert.getButton(Dialog.BUTTON_POSITIVE);
        btnPositive.setTextSize(TEXT_SIZE);

        ButtonbtnNegative= alert.getButton(Dialog.BUTTON_NEGATIVE);
        btnNegative.setTextSize(TEXT_SIZE);
    }
});

return alert;

Solution 4:

Why do you want to? The system will construct a standard dialog layout on your behalf that follows conventions that the user expects and is familiar with. In general you should not go out of your way to circumvent this.

Post a Comment for "Size Of Button In Alertdialog"