1
I’m trying to convey a message from Toast on top of a Activity common, when clicking on a Button, using the method setGravity(Gravity.TOP, 0, 0)
in API Level 30 (release R), however not working. The original section, in Kotlin, would be the following:
val toast = Toast.makeText(
this,
R.string.correct_toast,
Toast.LENGTH_SHORT)
toast.setGravity(Gravity.TOP, 0, 0)
toast.show()
In the API Level 29 (release Q) works normally. Looking at the documentation, (https://developer.android.com/reference/kotlin/android/widget/Toast#setgravity), I came across a Warning saying that the Toast.setGravity is as no-op in API Build.VERSION_CODES#R. I don’t quite understand what that is Build.VERSION_CODES#R I mean, but apparently it doesn’t seem to work in Build new (specifically in the Level 30). How could I get around this by using the API Level 30? Or really in the Build newer can no longer use the setGravity?
The Warning mentioned above:
Warning: Starting from Android Build.VERSION_CODES#R, for apps Targeting API level Build.VERSION_CODES#R or Higher, this method is a no-op when called on text toasts.