How to display Toast in different positions 2

My card activity, showing n number of overlays, when I click on the overlay icon, the toast is displayed at the bottom of the screen, but I want to display the Toast next to the overlay icon where I click.

I ask you, thanks, in advance ...

+3
source share
4 answers

This code gives me the exact position of the toast ...   This code gives me the exact weight of the 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 also skip points.

+5
source

Try to find here:

How to change the position of Toast on Android?

It mentions how to position a Toast post using setGravity (). You want to use the coordinates (x, y) of your pin to set the location of your toast.

+1
source

, . setGravity(int, int, int). : , x-position offset a y-position offset.

, , , :

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

, . , .

: Google

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

Gravity.TOP LEFT RIGHT

0

All Articles