I was wondering if there was a way to display all text in a toast to be centered. For instance, I have a toast that has 2 lines of text in it. For purely aesthetic reasons,
Without the hacks:
String text = "Some text";
Spannable centeredText = new SpannableString(text);
centeredText.setSpan(new AlignmentSpan.Standard(Layout.Alignment.ALIGN_CENTER),
0, text.length() - 1,
Spannable.SPAN_INCLUSIVE_INCLUSIVE);
Toast.makeText(getActivity(), centeredText, Toast.LENGTH_LONG).show();
There are also another alignments besides center.
source