How Android changes the default location of toast

The default location of toast in Android is near the bottom of the screen, which is sometimes inappropriate. For example, when there is less content on the page, the content is generally focused on the top half of the screen, and the user's attention is also focused on the top half of the screen. Toast users in the default location may not notice. It is also possible that the toast in the default position is blocked by the user's hand. In practice, it feels better to display toast in the middle or upper part of the screen. How to modify the default location of toast? Here is a simple example to demonstrate.

First screenshot:

Layout file activity_ The toast.xml code is as follows:

The background toast activity.java code is as follows:

The above Android method to change the default location of toast is all the content shared by Xiaobian. I hope it can give you a reference and support more programming tips.

The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
分享
二维码
< <上一篇
下一篇>>