Is it possible to right-justify the text in an AlertDialog\'s title and message?
I am showing Hebrew messages but they are showing up left justified.
If you want a quick and easy way to do this, I would just create and modify the default alert using AlertDialog.Builder. You can even create a convenience method and class like so:
/** Class to simplify display of alerts. */
public class MyAlert {
public static void alert(Context context, String title, String message, OnClickListener listener)
{
AlertDialog.Builder builder = new AlertDialog.Builder(context);
builder.setTitle("My Title");
builder.setMessage("My message");
builder.setPositiveButton("OK", listener);
AlertDialog dialog = builder.show();
// Must call show() prior to fetching views
TextView messageView = (TextView)dialog.findViewById(android.R.id.message);
messageView.setGravity(Gravity.RIGHT);
TextView titleView = (TextView)dialog.findViewById(context.getResources().getIdentifier("alertTitle", "id", "android"));
if (titleView != null) {
titleView.setGravity(Gravity.RIGHT);
}
}
}
Of course you could also change the gravity to CENTER for center alignment instead of right or the default left.