在Android中举杯中心文中心、Android

2023-09-11 07:36:17 作者:池暝

我在想,如果有一种方式来显示举杯所有文本为中心。举例来说,我有一个烤面包已在其2行文字。对于纯粹的审美原因,我想文本居中对齐,而不是左对齐。我已经通过的文​​件看,找不到任何关于它。有一个简单的方法来做到这一点,我已经错过了?

I was wondering if there was a way to display all text in a toast to be centered. For instance, I have a toast that has 2 lines of text in it. For purely aesthetic reasons, I would like the text to center-aligned instead of left-aligned. I've looked through the documentation and can't find anything about it. Is there a simple way to do this that I have missed?

谢谢 克里斯

推荐答案

使用的吐司的的setView(视图)功能提供与Gravity.CENTER视图

Use the Toast's setView(view) function to supply a View with Gravity.CENTER