--ADVERTISEMENT--

A toast is a view that provides quick feedback for the user in a small popup. Normally, Android toast is displayed at the bottom of the screen but you can also change the position. In this example, I will show how to use custom toast in android app. Custom android toast allows you to display little message with small image icon and lot more. With custom toast, you can change toast background color, text color and style and even more. You can use Snackbar instead of toast. Snackbar is similar to toast with even more features.

How to Create a Custom Toast in AndroidRelated:
How to Display Simple Toast Message in Android
Android Snackbar Using Design Support Library
Android Action Bar Tutorial and Example With Option Menu

How to Display Custom Toast in Android App


Just follow the following simple steps to display custom android toast message.


Create an XML Layout File


To display custom toast, you have to create an xml layout file and add what you want to display in the toast. Here, I have created a custom_toast.xml file and it looks like this.
res/layout/custom_toast.xml


Modify XML Activity Layout File 


Add a button to your activity_main.xml file and it looks like this.
res/layout/activity_main.xml


Modify Your Java Activity File


This is the modified code of java activity.
src/MainActivity.java


The job you have to do is over. Now, run your application which looks like this.

Android Custom Toast View
Custom Toast

Post a Comment

Powered by Blogger.