From the documentation:
Warning: Starting from Android Build.VERSION_CODES#R, for apps targeting API level Build.VERSION_CODES#R or higher, this method (setGravity) is a no-op when called on text toasts.
Which means that setGravity
can no longer be used in API 30+ and will have to find another to achieve the required behaviour.