- A Toast is a short alert message shown on the Android screen for a short interval of time.
- Android Toast is a short popup notification which is used to display an information when we perform any operation in our app.
Toast.makeText() creates a toast and returns it and we should pass three parameters:
- context – The context to use. Usually your
- text – The text to show. Can be formatted
- duration – How long to display the message.
val messageEditText = findViewById(R.id.messageEditText) val message = messageEditText.text.toString() var toast = Toast.makeText(this, message, Toast.LENGTH_LONG) toast.show()
Another Direct way to use :
Toast.makeText(this, message, Toast.LENGTH_LONG).show() // Message is String that to display
Toast.makeText(this, message, Toast.LENGTH_SHORT).show() // Message is String that to display
Toast Function
- As topic said if we have show toast multiple times during app we Can Simply make function that will take context and message as arguments from function call and function will be execute to make toast every time.
fun showToast( var page : Contex , var message : String){ Toast.makeText(page, message, Toast.LENGTH_SHORT).show() }
- So every time when we call
showToast(this@Main,”hello”)like this toast message will be appear on screen
Making custom toast with layout
- we can create custom toast like this where we set our custom view in it to display
- here we can pass message to the textview of layout or set in textview view in layout
fun customToast(view: View) { val toast = Toast(applicationContext) toast.duration = Toast.LENGTH_LONG toast.view = layoutInflater.inflate(R.layout.custom_toast, findViewById(R.id.customnoti)) toast.show() }
Library to Create Custom Toast Easily
⇒ Link To fancy toast github page
FancyToast-Android
Shashank02051997 • Updated Oct 21, 2025
MotionToast
Spikeysanju • Updated Nov 6, 2025
⇒ Link to custom toast github page
Toastic
yagmurerdogan • Updated Jan 26, 2025
Android-Custom-Toast-Message
emreesen27 • Updated Oct 4, 2025
- Using this Library We can Create And Style Custom Toast Easily