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.OnClickListener() { public void onClick(DialogInterface dialog, int which) { } });
you may try this code:
AlertDialog.Builder adb = new AlertDialog.Builder(this);
Dialog d = adb.setView(new View(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.LayoutParams lp = new WindowManager.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
you should use a customView for your case to change the button layout. see the following link on how to make your own view for alertDialog.
How to implement a custom AlertDialog View
Try this :
https://stackoverflow.com/a/15910202/305135
final AlertDialog alert = builder.create();
alert.setOnShowListener(new DialogInterface.OnShowListener() {
@Override
public void onShow(DialogInterface dialog) {
Button btnPositive = alert.getButton(Dialog.BUTTON_POSITIVE);
btnPositive.setTextSize(TEXT_SIZE);
Button btnNegative = alert.getButton(Dialog.BUTTON_NEGATIVE);
btnNegative.setTextSize(TEXT_SIZE);
}
});
return alert;
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.