In this Tutorial you will learn how to create a Custom Toast Image , when clicking a button or activating a toast.
When starting out , you will need to firsly install Android Studio , and once that has been taken care of your able to start creating your custom toast! After Android Studio is installed start it up , and create a new project and the image below will help , select the Empty Views Activity.
After that select the following settings and the attached screen shot is there for help.
- Name : CustomToast
- Package Name : com.LOCATION.customtoast
- Save Location : C:\Users\StormTroopers\Desktop\CustomToast
- Langauge: Java
- Minimum SDK: API 21: Android 5.0 (Lollipop)
Now , you can make this image anything you like but for this tutorial im going to be using a checkmark image. Download the image , and then copy and paste it in the drawable-v24 folder , along with other two ic_launcher files that should already be in there.
Firsly, go to your main activity_main.xml and change all of the code to the photo below!
Here , is what your layout should look like now.
Now you done with activity_main.xml file we can move on to the other files we will add a total of two more files.
Fill in the toast.xml file with the code below.
You will need to change the android:orientation="vertical" to "horizontal".
Create the new toast_border.xml.
Then fill in the toast_border.xml file with the code below in the screenshot.
Now afther this step all we need to do to finish this project is edit the MainActivity.java.
Add the code below in the screenshots , to the MainActivity.java
Now run the module and hit the button and you should get this result below.
If you have any questions please check out the video tutorial.