The alert message by default is too big for specific devices with little screens and I want to set it to a custom dp
My alert is something like this
OnClickListener addNewItemListener = new OnClickListener() {
public void onClick(View v) {
AlertDialog.Builder alert = new AlertDialog.Builder(
MyActivity.this);
LinearLayout myLayout= new LinearLayout(MyActivity.this);
myLayout.setOrientation(LinearLayout.VERTICAL);
alert.setTitle(R.string.add_title);
alert.setMessage(R.string.add_message);
final TextView t1 = new TextView(MyActivity.this);
t1.setText("Name");
final EditText input1 = new EditText(MyActivity.this);
myLayout.addView(t1);
myLayout.addView(input1);
alert.setView(myLayout);
alert.setPositiveButton(R.string.cancel,
new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog,
int whichButton) {
}
});
alert.setNegativeButton(R.string.ok,
new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog,
int whichButton) {
try {
....
} catch (RuntimeException e) {
Alerts.DatiErrati(MyActivity.this);
}
}
});
alert.show();
}
};
How could I set the text size of the alert message?
EDIT 2:
This is the best method you can go with
AlertDialog.Builder builder = new Builder(this);
builder.setMessage("Record and Images will be deleted?")
.setTitle("MyTitle")
.setCancelable(true)
.setPositiveButton("Yes",
new DialogInterface.OnClickListener()
{
public void onClick(DialogInterface dialog,
int id)
{
dialog.cancel();
finish();
}
})
.setNegativeButton("No",
new DialogInterface.OnClickListener()
{
public void onClick(DialogInterface dialog,
int id)
{
dialog.cancel();
}
});
AlertDialog dialog = builder.create();
dialog.show();
TextView textView = (TextView) dialog.findViewById(android.R.id.message);
textView.setTextSize(40);
You can use the following to get bigger text only
alert.setMessage(Html.fromHtml("<Big>"+getString(R.string.add_message)+"</Big>"));
Note: you can use more big's for more bigger text
Try this:
AlertDialog dialog = new AlertDialog.Builder(this).setMessage("Hello world").show();
TextView textView = (TextView) dialog.findViewById(android.R.id.message);
textView.setTextSize(40);
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