Siva K Siva K -5 years ago 175
Android Question

Center message in android dialog box

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

Answer Source

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);

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.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download