Toast构建在TextView上,其默认重力左对齐.因此,您需要创建自己的TextView,例如:
<TextView
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:gravity="center_vertical|center_horizontal"
android:text="all the text you want" />
Run Code Online (Sandbox Code Playgroud)
并将TextView分配给Toast,如下所示:
Toast t = new Toast(yourContext);
t.setView(yourNewTextView);
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
6545 次 |
| 最近记录: |