Violin Nz Violin Nz - 1 year ago 177
Android Question

How to center text in Alert Dialog Builder?

I'm trying to center some text in a default Alert Dialog Builder
Here's my code so far, but it defaults to the left.

new AlertDialog.Builder(getActivity())
.setTitle("Well done!")
.setMessage("Message centered????")

new DialogInterface.OnClickListener() {

public void onClick(DialogInterface dialog,
int which) {
// TODO Auto-generated method stub




Answer Source

Instead of setting the message, use AlertDialog.Builder.setView(View) with a View with centred text

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