Android Custom Toast example

Android Toast is used to display message for short span of time. Message appears on the screen for short span of time then disappears after some time.

We have already used toast in previous examples like Android SeekBar , Android RatingBar .
In this post, I am going to demonstrate how to make custom toast and use in your app.

Source code:

Lets create Android custom toast example:

Step 1 : Creating Project

Create an android application project named “CustomToastExampleApp”.

Step 2: Put any image in drawable folder with name “custom_toast_image”

Step 3 : Creating custom toast layout file

  • Go to res -> layout
  • Right click on layout
  • Click on New -> File.
  • Create a file named “custom_toast.xml” and paste below code in custom_toast.xml.

💻 Awesome Tech Resources:
  • Looking for ⚒️ tech jobs? Go to our job portal.
  • Looking for tech events? Go to tech events 🗓️ Calendar.️

Step 4 : Creating Layout

Change res ->layout -> activity_main.xml as below:

Step 5 : Creating MainActivity

Change src/main/packageName/ as below:

It is default MainActivity provided by HelloWorld app.

Step 6 : Running the app

When you run the app, you will get below screen:

When you click on the button, you will get below screen.

Related Posts

Leave a Reply

Your email address will not be published. Required fields are marked *

Subscribe to our newletter

Get quality tutorials to your inbox. Subscribe now.