While optimizing an app for material theme on lollipop, I\'m encountering this annoying problem:
Whenever there is long text on dialog buttons, that doesn\'t fit the but
use following code, let buttons on the right and vertical arrangement
alertDialog.setOnShowListener(new DialogInterface.OnShowListener() {
@Override
public void onShow(DialogInterface dialog) {
try {
LinearLayout linearLayout = (LinearLayout) alertDialog.getButton(DialogInterface.BUTTON_POSITIVE).getParent();
if (linearLayout != null) {
linearLayout.setOrientation(LinearLayout.VERTICAL);
linearLayout.setGravity(Gravity.RIGHT);
}
} catch (Exception ignored) {
}
}
});