How to Change the alignment of Toast by Programmatically? [duplicate]
开发者_开发技巧Possible Duplicate:
how to change position of Toast in android?
How to change the Alignment for Toast? Basically, toast it'll displays information bottom of the device. How can we change that? Anyone help me to find out this? Thanks in Advance.
It would be a nice idea to create a Custom Toast like this,
TextView textview = new TextView(context);
textview.setText(text);
textview.setBackgroundColor(Color.GRAY);
textview.setTextColor(Color.BLUE);
textview.setPadding(10,10,10,10);
Toast toast = new Toast(context);
toast.setView(textview);
toast.setDuration(Toast.LENGTH_LONG);
toast.setGravity(Gravity.BOTTOM, 0, 0);
toast.show();
By this you can place the Toast to anywhere you want using Gravity
精彩评论