My map activity displaying n number of overlay, when I am tapping on overlay icon then toast is displaying on bottom of screen, But I want to display the Toast near by overlay icon where I am tapping.
Asked
Active
Viewed 3,759 times
3
-
possible duplicate of [how to change position of Toast in android?](http://stackoverflow.com/questions/2506876/how-to-change-position-of-toast-in-android) – Graham Borland May 25 '12 at 15:10
2 Answers
5
This code is giving me exact position of toast... This code is giving me exact gravity of toast..
OverlayItem item = overlayItems_.get(index);
Projection projection = mMapView.getProjection();
Point point = new Point();
projection.toPixels(item.getPoint(), point);
Toast toast = Toast.makeText(mContext, item.getTitle()+" "+item.getSnippet(), Toast.LENGTH_SHORT);
toast.setGravity(Gravity.TOP | Gravity.LEFT, point.x, point.y);
toast.show();
Here i am passing points also..

Vishesh Chandra
- 6,951
- 6
- 35
- 38
0
toast.setGravity(Gravity.TOP, 0, 0);
Instead of Gravity.TOP you could also use LEFT
or RIGHT

Thkru
- 4,218
- 2
- 18
- 37
-
Thanks to help me, but this solution is giving the gravity of toast to only LEFT, RIGHT, TOP, BOTTOM, but i need toast gravity where ever i am tapping the overlay icon, Now finally i got solution.. – Vishesh Chandra May 28 '12 at 05:35