Search code examples
androidandroid-toast

What does the first argument do in toast.setGravity


Toast toast = Toast.makeText(this, "Toast!!!", Toast.LENGTH_SHORT); 
toast.setGravity(Gravity.AXIS_PULL_AFTER , 0, 0); toast.show(); 

what is the role of Gravity.AXIS_PULL_AFTER argument in order to positiong the Toast on the UI.


Solution

  • As per Android documentation:

    Make a standard toast that just contains a text view.

    Context: The context to use. Usually your Application or Activity object.

    Generally, this will be a reference to the activity calling Toast. However, if you are inside an anonymous class (for example, creating a click listener for a button), you will lose reference to your activity.