Android应用中Toast的位置如何更改?针对这个问题,这篇文章详细介绍了相对应的分析和解答,希望可以帮助更多想解决这个问题的小伙伴找到更简单易行的方法。Android中Toast的默认位置在屏幕靠近底部的位置,这个默认位置有时候并不合
Android应用中Toast的位置如何更改?针对这个问题,这篇文章详细介绍了相对应的分析和解答,希望可以帮助更多想解决这个问题的小伙伴找到更简单易行的方法。
Android中Toast的默认位置在屏幕靠近底部的位置,这个默认位置有时候并不合适。比如页面上内容较少时,内容一般集中在屏幕上半部分,用户的注意力也集中在屏幕上半部分,默认位置的Toast用户可能没有注意到。还有可能是默认位置的Toast被用户的手挡住了。实践中感觉将Toast显示在屏幕的中部或中上部会比较好。如何修改Toast的默认位置呢?
布局文件activity_toast.xml代码如下:
<?xml version="1.0" encoding="utf-8"?><LinearLayout xmlns:android="Http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="vertical" > <Button android:layout_width="fill_parent" android:layout_height="wrap_content" android:onClick="onClickDefaultToast" android:text="点击显示默认位置的Toast" /> <Button android:layout_width="fill_parent" android:layout_height="wrap_content" android:onClick="onClickCenterToast" android:text="点击显示居中位置的Toast" /> <Button android:layout_width="fill_parent" android:layout_height="wrap_content" android:onClick="onClickTopToast" android:text="点击显示居中上部位置的Toast" /></LinearLayout>
--结束END--
本文标题: Android应用中Toast的位置如何更改
本文链接: https://www.lsjlt.com/news/223822.html(转载时请注明来源链接)
有问题或投稿请发送至: 邮箱/279061341@qq.com QQ/279061341
下载Word文档到电脑,方便收藏和打印~
2024-05-24
2024-05-24
2024-05-24
2024-05-24
2024-05-24
2024-05-24
2024-05-24
2024-05-24
2024-05-24
2024-05-24
回答
回答
回答
回答
回答
回答
回答
回答
回答
回答
0