我的alertDialog中有一个4行文本,我希望集中对齐它,而不提供任何自定义布局.这是可能的. 你能行的.通过在代码中设置标准对话框的消息文本元素的重力,居中对齐标准AlertView对话框,如下
AlertDialog.Builder builder = new AlertDialog.Builder(this); builder.setTitle("Title"); builder.setMessage("Message"); builder.setPositiveButton("OK", null); AlertDialog dialog = builder.show(); // the following line gets a handler to the message element inside the dialog. TextView messageText = (TextView)dialog.findViewById(android.R.id.message); // and now all that is needed is changing the gravity ... messageText.setGravity(Gravity.CENTER);