你的位置:首页 > 软件开发 > 操作系统 > Android 更改 Toast 的默认位置

Android 更改 Toast 的默认位置

发布时间:2015-12-10 13:01:19
Android中Toast的默认位置在屏幕靠近底部的位置,这个默认位置有时候并不合适。比如页面上内容较少时,内容一般集中在屏幕上半部分,用户的注意力也集中在屏幕上半部分,默认位置的Toast用户可能没有注意到。还有可能是默认位置的Toast被用户的手挡住了。实践中感觉将Toast ...

Android 更改 Toast 的默认位置

Android中Toast的默认位置在屏幕靠近底部的位置,这个默认位置有时候并不合适。比如页面上内容较少时,内容一般集中在屏幕上半部分,用户的注意力也集中在屏幕上半部分,默认位置的Toast用户可能没有注意到。还有可能是默认位置的Toast被用户的手挡住了。实践中感觉将Toast显示在屏幕的中部或中上部会比较好。如何修改Toast的默认位置呢?下面做一个简单的例子来演示一下。

先上截图:

Android 更改 Toast 的默认位置

Android 更改 Toast 的默认位置

Android 更改 Toast 的默认位置

布局文件activity_toast.

<??><LinearLayout ="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>

 

海外公司注册、海外银行开户、跨境平台代入驻、VAT、EPR等知识和在线办理:https://www.xlkjsw.com

原标题:Android 更改 Toast 的默认位置

关键词:Android

*特别声明:以上内容来自于网络收集,著作权属原作者所有,如有侵权,请联系我们: admin#shaoqun.com (#换成@)。

可能感兴趣文章

我的浏览记录