Search code examples
androidtoast

How to set Toast display time less than Toast.LENGTH_SHORT


I want to display toast less than Toast.LENGTH_SHORT, as i feel its taking around 2 seconds. i want to display toast only for half second.

And what is time interval for Toast.LENGTH_SHORT and Toast.LENGTH_LONG ?


Solution

  • There are only two possible values:

    private static final int LONG_DELAY = 3500; // 3.5 seconds
    private static final int SHORT_DELAY = 2000; // 2 seconds
    

    Setting other values doesn't work. If duration not equals 1 (Toast.LENGTH_LONG), then duration will be SHORT_DELAY (2 seconds):

    long delay = immediate ? 0 : (r.duration == Toast.LENGTH_LONG ? LONG_DELAY : SHORT_DELAY);
    

    In sources of Toast written that

    This time could be user-definable.

    but I can't find way to do this.

    Update: There is solution here: Set Toast Appear Length