如何设置警报对话框警报文本大小 [英] How to set Alert text size in alert dialog
本文介绍了如何设置警报对话框警报文本大小的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
默认警报消息是太大了,几乎没有屏幕的特定设备,我想将它设置为自定义DP
The alert message by default is too big for specific devices with little screens and I want to set it to a custom dp
我的提醒是这样
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?
推荐答案
编辑2:
这是你可以用
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
这篇关于如何设置警报对话框警报文本大小的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文