Material Design Tasty Toast in android

Material design is a comprehensive guide for visual, motion, and interaction design across platforms and devices.In this tutorial we will explain how to work with Android Toast with example. The example below demonstrates the usages of simple and customized toast in Android.
1. Toast is a solution for android developer when required to notify user about an operation without expecting any user input.
2.This provides a small popup that displays for a small period and fades out automatically after timeout. Sometimes developers use this for debugging.

1. MainActivity.java

package com.tutorialsee;

import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.view.View;
import android.view.WindowManager;

import com.tutorialsee.lib.TastyToast;


public class MainActivity extends AppCompatActivity {


    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
    }

    public void showSuccessToast(View view) {
        TastyToast.makeText(getApplicationContext(), "Download Successful !", TastyToast.LENGTH_LONG,
                TastyToast.SUCCESS);
    }

    public void showWarningToast(View view) {
        TastyToast.makeText(getApplicationContext(), "Are you sure ?", TastyToast.LENGTH_LONG,
                TastyToast.WARNING);
    }

    public void showErrorToast(View view) {
        TastyToast.makeText(getApplicationContext(), "Downloading failed ! Try again later ", TastyToast.LENGTH_LONG,
                TastyToast.ERROR);
    }
    public void showInfoToast(View view) {
        TastyToast.makeText(getApplicationContext(), "Searching for username : 'Rahul' ", TastyToast.LENGTH_LONG,
                TastyToast.INFO);
    }

    public void showDefaultToast(View view) {
        TastyToast.makeText(getApplicationContext(), "This is Default Toast", TastyToast.LENGTH_LONG,
                TastyToast.DEFAULT);
    }
}

2. activity_main.xml

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:background="#607D8B"
    android:orientation="vertical"
    tools:context=".MainActivity" >

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:layout_weight="1"
        android:layout_margin="3dp"
        android:orientation="horizontal" >

        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:layout_weight="1"
            android:gravity="center"
            android:orientation="horizontal" >

            <Button
                android:id="@+id/button"
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                android:onClick="showSuccessToast"
                android:background="#B0BEC5"
                android:textColor="#37474F"
                android:textSize="15sp"
                android:text="Download" />
        </LinearLayout>

        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:layout_weight="1"
            android:gravity="center"
            android:orientation="horizontal" >

            <Button
                android:id="@+id/button2"
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                android:onClick="showWarningToast"
                  android:background="#B0BEC5"
                   android:textColor="#37474F"
                android:textSize="15sp"
                  android:layout_marginLeft="3dp"
                  android:layout_marginRight="3dp"
                android:text="Warning" />
        </LinearLayout>

        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:layout_weight="1"
            android:gravity="center"
            android:orientation="horizontal" >

            <Button
                android:id="@+id/button3"
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                android:onClick="showErrorToast"
                  android:background="#B0BEC5"
                   android:textColor="#37474F"
                android:textSize="15sp"
                android:text="Error" />
        </LinearLayout>
    </LinearLayout>

   
  
   
    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:layout_weight="1"
        android:layout_marginLeft="3dp"
        android:layout_marginRight="3dp"
        android:orientation="horizontal" >

        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:layout_weight="1"
            android:gravity="center"
            android:orientation="horizontal" >

            <Button
                android:id="@+id/button4"
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                android:onClick="showInfoToast"
                  android:background="#B0BEC5"
                   android:textColor="#37474F"
                android:textSize="15sp"
                android:text="Info" />
        </LinearLayout>

        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:layout_weight="1"
            android:layout_marginLeft="3dp"
            android:gravity="center"
           
            android:orientation="horizontal" >

            <Button
                android:id="@+id/button5"
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                android:onClick="showDefaultToast"
                  android:background="#B0BEC5"
                   android:textColor="#37474F"
                android:textSize="15sp"
                android:text="Default" />
        </LinearLayout>
        </LinearLayout>
       
      <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:layout_weight="1"
        android:layout_margin="3dp"
        android:orientation="horizontal" >

        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:layout_weight="1"
            android:gravity="center"
            android:orientation="horizontal" >

            <Button
                android:id="@+id/button"
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                android:onClick="showSuccessToast"
                 android:textColor="#37474F"
                android:textSize="15sp"
                  android:background="#B0BEC5"
                android:text="Download" />
        </LinearLayout>
   
    </LinearLayout>
    </LinearLayout>