Vishesh Chandra
Vishesh Chandra

Reputation: 7071

How to display Toast in different- 2 position

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.

Upvotes: 3

Views: 3778

Answers (2)

Vishesh Chandra
Vishesh Chandra

Reputation: 7071

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..

Upvotes: 5

Thkru
Thkru

Reputation: 4199

toast.setGravity(Gravity.TOP, 0, 0);

Instead of Gravity.TOP you could also use LEFT or RIGHT

Upvotes: 0

Related Questions