I have created a AlertDialog in my app. Before Android L AlertDialog buttons fit in dialog box, but in Android L buttons label automatically converts in title case and buttons not fit in dialog box. Please see screenshots:
Android L:
Android Kitkat:
Is anybody see this issue. Can any help me to solve this problem, although this is latest android version.
Code: (I have not used xml code to create dialog, here is java code:)
AlertDialog.Builder alert = new AlertDialog.Builder(this);
alert.setTitle(R.string.feedback_label);
alert.setMessage(msgStrId);
alert.setNegativeButton(R.string.close_label, new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
// TODO Auto-generated method stub
}
});
alert.setPositiveButton(R.string.rate_app, new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
// TODO Auto-generated method stub
}
});
alert.setNeutralButton(R.string.feedback_label,new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which)
{
// TODO Auto-generated method stub
}
});
alert.setOnCancelListener(new DialogInterface.OnCancelListener()
{
@Override
public void onCancel(DialogInterface dialog)
{
// TODO Auto-generated method stub
}
});
AlertDialog alertDialog = alert.create();
alertDialog.show();
AlertDialog. A dialog that can show a title, up to three buttons, a list of selectable items, or a custom layout.
AlertDialog generally consists of the main title, the message, and two buttons, technically termed as a positive button and a negative button. Both positive and negative buttons can be programmed to perform various actions. By default, the negative button lets close the AlertDialog without any additional lines of code.
AlertDialog is a lightweight version of a Dialog. This is supposed to deal with INFORMATIVE matters only, That's the reason why complex interactions with the user are limited. Dialog on the other hand is able to do even more complex things .
Alert Dialog shows the Alert message and gives the answer in the form of yes or no. Alert Dialog displays the message to warn you and then according to your response the next step is processed. Android Alert Dialog is built with the use of three fields: Title, Message area, Action Button.
I know, I am too late. But I share my suggestion here. Maybe it will be helpful.
AlertDialog alertDialog = alert.create();
alertDialog .show();
alertDialog.getButton(DialogInterface.BUTTON_NEGATIVE).setAllCaps(false);
alertDialog.getButton(DialogInterface.BUTTON_POSITIVE).setAllCaps(false);
alertDialog.getButton(DialogInterface.BUTTON_NEUTRAL).setAllCaps(false);
alertDialog.show();
AlertDialog.Builder builder = new AlertDialog.Builder(this, R.style.MyAlertDialogStyle);
styles.xml
<style name="MyAlertDialogStyle" parent="Theme.AppCompat.Light.Dialog">
<item name="android:textAllCaps">false</item>
</style>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With