默认情况下的警报消息对于屏幕较小的特定设备来说太大,我想将其设置为自定义 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();
}
};
如何设置警报消息的文本大小?
EDIT 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);
您可以使用以下方法仅获取更大的文本
alert.setMessage(Html.fromHtml("<Big>"+getString(R.string.add_message)+"</Big>"));
Note:你可以使用更多big's以获得更大的文本
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)