If you want to move the toast message towards the right side, increase this value. You can set the position of toast message using gravity constants, Gravity.TOP To get a location at which the notification should appear on the screen it has 3 parameters, If you want to display the toast message at the different position then you can use setGravity() method. You can display toast as one statement too, Toast.makeText(this, "Hello, this is a android toast message!", Toast.LENGTH_LONG).show() īy default the toast message is displayed at the bottom of an Activity screen aligned vertically. Private static final int SHORT_DELAY = 2000 // 2 seconds So what you can do here is you just need to give the name of your activity, pass that as the first. ⛏️ "Expected duration Toast.LENGTH_SHORT or Toast.LENGTH_LONG, a custom duration value is not supported"Īctual duration of these constants are 3.5 seconds for LONG_DELAY and 2 seconds for SHORT_DELAY, private static final int LONG_DELAY = 3500 // 3.5 seconds maketext and inside this make text you can display a message. Note that you can only have these two values for the duration of toast message, If you define a custom duration as Integer value you will get a warning message in the gutter area saying, Toast.makeText(this, "Hello", 5000)
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |