How to customize Toasts

SDK Version: 

Customizing Toasts

A toast notification is a message that pops up on the surface of the window. It only fills the amount of space required for the message and the user's current activity remains visible and interactive. The notification automatically fades in and out, and does not accept interaction events.

The Basics

You can create customized Toasts and setting its display position, as you like.
Here's a little code snippet to demonstrate how it works:

  1.        String text = “example toast text!;
  2.        Toast toast = Toast.makeText(getApplicationContext(), text, Toast.LENGTH_SHORT);
  3.        /* Positioning your Toast */
  4.        int offsetX = 0, offsetY = 0;
  5.        toast.setGravity(Gravity.BOTTOM, offsetX, offsetY);

Creating a Custom Toast View

Syndicate content