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..
Please guide me, Thanks in advance...
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..
Please guide me, Thanks in advance...
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..
Try looking here:
How to change position of Toast in Android?
It mentions how to position your Toast message using setGravity(). You'll want to use the (x,y) coordinates of your pin to set the location of your Toast.
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.
Source: Google Developers
toast.setGravity(Gravity.TOP, 0, 0);
Instead of Gravity.TOP you could also use LEFT or RIGHT