Toasts - jorgepascoPE/Kotlin-snippets GitHub Wiki

A toast is a view containing a quick little message for the user. The toast class helps you create and show those. When the view is shown to the user, appears as a floating view over the application. It will never receive focus.

Documentation

Basics

val context = this
val length = Toast.LENGTH_SHORT

val toast = Toast.makeText (context, "Message to display", length)
toast.show()

Positioning Toast

A toast is shown by default centered horizontally in the bottom of the screen, but its position can be specified as follows:

toast.setGravity(Gravity.TOP or Gravity.LEFT, x-offset, y-offset) //