在Android的对话框中心消息对话框、消息、中心、Android

由网友(海是一座无墙的城)分享简介:我想在我的对话框中的消息文本为中心对齐。I want the message text within my dialog box to be center aligned.推荐答案创建自己的TextView的对象,然后将其提供给弹出建设者查看:Create your own TextView object an...

我想在我的对话框中的消息文本为中心对齐。

I want the message text within my dialog box to be center aligned.

推荐答案

创建自己的TextView的对象,然后将其提供给弹出建设者查看:

Create your own TextView object and then supply it to popup builder as 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的内容。

You can control all other text parameters (style, color, size ...). To control margins you may programatically create LinearLayout, set LayoutParams, and then put TextView into it.

阅读全文

相关推荐

最新文章