Reputation: 2789
I have the following code:
AlertDialog.Builder b = new AlertDialog.Builder(MainActivity.this, R.style.AppDialogTheme);
b.setTitle(R.string.opt_out_dialog_title);
b.setMessage(R.string.opt_out_dialog_message);
b.show();
My String: R.string.opt_out_dialog_message
displays sometimes two lines and sometimes three lines within the dialog. I'm wondering if there is a way to restrict it or fix it to a 2 lines max?
Upvotes: 0
Views: 840
Reputation: 3054
You can create a custom view and set it to your dialog by setContentView
.
Or you can try this though it's not official(might not work in all OS, device):
Dialog dlg = b.show();
TextView tv = (TextView) dlg.findViewById(android.R.id.message);
tv.setMaxLines(2);
Hope that helps.
Upvotes: 2