Harmony Valley
Harmony Valley

Reputation: 145

Toast "setGravity" doesn't work on fragment

All the toasts I use in a fragment are shown in the same place. I tried to change the position using this code:

val t = Toast.makeText(
    context,
    "hello",
    Toast.LENGTH_LONG
)
t.setGravity(Gravity.TOP, 0, 0)
t.show()

but it doesn’t change anything at all. I’m not sure if I have to do anything else because this code is in a fragment, not in the main Activity. Thanks!

Upvotes: 0

Views: 249

Answers (0)

Related Questions