I want to position my Toast on that position on screen on which the touch event occurs in android. How o achieve that??
Asked
Active
Viewed 171 times
0
-
Check this question http://stackoverflow.com/questions/10756646/how-to-display-toast-in-different-2-position – Mohamed_AbdAllah Sep 24 '12 at 14:01
-
hello fahad.. if you satisfy with my ans then put the "Green Right Mark".... thankx in adv.. – Hardikgiri Goswami Sep 24 '12 at 14:19
-
possible duplicate of [how to change position of Toast in android?](http://stackoverflow.com/questions/2506876/how-to-change-position-of-toast-in-android) – Gordon Sep 24 '12 at 17:37
1 Answers
3
Positioning your Toast
A standard toast notification appears near the bottom of the screen, centered horizontally. You can change this position with the setGravity(int, int, int) method. This accepts three parameters: a Gravity constant, an x-position offset, and a y-position offset.
For example, if you decide that the toast should appear in the top-left corner, you can set the gravity like this:
toast.setGravity(Gravity.TOP|Gravity.LEFT, 0, 0);
If you want to nudge the position to the right, increase the value of the second parameter. To nudge it down, increase the value of the last parameter.
REF : http://developer.android.com/guide/topics/ui/notifiers/toasts.html
and
Community
- 1
- 1
Hardikgiri Goswami
- 544
- 3
- 13