Search code examples
c#androidmonodeveloptoastitemizedoverlay

Display text under overlay item


I am using MonoDevelop for Android with Google maps and overlays.

My question is this: How can I add a brief section of text under each overlay item?

This is the code I normally use to display text:

var toast = Toast.MakeText (this, "Test", ToastLength.Short);

This works, yet it is placed at the bottom of the map. I am after the same idea, yet I can position the text under each overlay item.

May I please have some help to do this?

Thanks

UPDATE

I have been given some code to set toast at a given offsetX and offsetY. May I please have some code to actually find the offsets for each overlay item that is drawn as ItemizedOverlay so that I can display toast text under each overlay item?


Solution

  • Try this to show toast at top :

    String text = “example toast text!”;
    Toast toast = Toast.makeText(getApplicationContext(), text, Toast.LENGTH_SHORT);
    
    /* Positioning your Toast */
    int offsetX = 0, offsetY = 0;
    toast.setGravity(Gravity.TOP, offsetX, offsetY);
    toast.show();
    

    Refer this link for more customization of Toast.