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,
Not saing that findViewById(android.R.id.message) is wrong, but just in case there are (future?) implementation differences I myself used a bit differen approach:
void centerText(View view) {
if( view instanceof TextView){
((TextView) view).setGravity(Gravity.CENTER);
}else if( view instanceof ViewGroup){
ViewGroup group = (ViewGroup) view;
int n = group.getChildCount();
for( int i = 0; i
and then:
Toast t = Toast.makeText(context, msg,Toast.LENGTH_SHORT);
centerText(t.getView());
t.show();