How to change toast alignment programmatically?

Possible duplicate:
How to change the position of Toast in android?

How to change the alignment for a toast? Basically, the toast will display information at the bottom of the device. How can we change that? Anyone help me figure this out? Thanks at Advance.

+4
source share
1 answer

It would be nice 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(); 

This way you can place your Toast wherever you want using Gravity

+21
source

All Articles