创建您自己的TextView对象,然后将其作为View提供给弹出窗口生成器:
alertDialog.Builder popupBuilder = new alertDialog.Builder(this);TextView myMsg = new TextView(this);myMsg.setText("Central");myMsg.setGravity(Gravity.CENTER_HORIZONTAL);popupBuilder.setView(myMsg);您可以控制所有其他文本参数(样式,颜色,大小…)。要控制边距,您可以以编程方式创建LinearLayout,设置LayoutParams,然后将TextView放入其中。



