Quantcast
Channel: How to change position of Toast in Android? - Stack Overflow
Viewing all articles
Browse latest Browse all 14

Answer by Ali Akram for How to change position of Toast in Android?

$
0
0

SOLUTION

fun Context.showToastOnTOP(message: String) = Toast.makeText(this, message, Toast.LENGTH_SHORT)    .apply { setGravity(Gravity.TOP, 0, 0); show() }fun Context.showToastOnBOTTOM(message: String) = Toast.makeText(this, message, Toast.LENGTH_SHORT)    .apply { setGravity(Gravity.BOTTOM, 0, 0); show() }

Important note Gravity will only work if your app target max 29 or less.

Chill Pill :)


Viewing all articles
Browse latest Browse all 14

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>