在Android的对话框中心消息 [英] Center message in android dialog box

查看:141
本文介绍了在Android的对话框中心消息的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

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.

这篇关于在Android的对话框中心消息的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆