如何增加 toast 中的字体大小?
有没有办法在不自定义的情况下增加toast中的字体大小?
我不想创建用于增加文本大小的布局。
有什么办法吗?
谢谢,
尼基
Is there any way to increase the font size in toast without customizing?
I don't want to create a layout for increasing the text size.
Is there any way?
Thanks,
Niki
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(9)
我相信这是可以实现的:
I believe it is achieveable by this:
这是...
this is ...
以下是如何使用跨度来做到这一点:
Here is how to do that with spans:
如果不创建
,则无法增加字体大小CustomToastView
。这是一个相关问题。
You can't increase the font size without creating a
CustomToastView
.This is a related question.
根据 Ani 的答案,另一种允许您将文本大小设置为尺寸值的解决方案如下所示:
这可以让您将 Toast 的大小与 TextView 和 Button 控件中指定的大小相匹配。
Working from Ani's answer, another solution that allows you to set the text size to a dimension value would be something like:
This lets you match the size you get your toasts to be the same size as specified in TextView and Button controls, for example.
尼古拉回答得很漂亮。试探性地,可以肯定的是,如果 Android API 方法采用
CharSequence
而不是String
,则意味着您可以传递它Spanned
(即格式化)文本。如果您不想手动构建它,并且更熟悉 HTML,您可以这样做:
或者,如果使用字符串资源,请执行以下操作:
然后像这样使用它:
可用的标记大多记录在 < a href="https://developer.android.com/guide/topics/resources/string-resource#StylingWithHTML" rel="nofollow noreferrer">此处。
Nikolay answered this beautifully. Heuristically, it's pretty a safe bet that, if an Android API method takes a
CharSequence
instead of aString
it means you can pass itSpanned
(i.e. formatted) text.If you don't want to want to build it by hand, and are more comfortable with HTML you can do this:
Or, if using a string resource, do this:
And just use it like this:
The available markup is mostly documented here.
试试这个:
SpreadsheetApp.getActive().toast(" ","你想要的文本在这里");
通过将第一组引号保留为空,第二组引号会将文本加粗并使其更易于阅读。
通常该行是: .toast("您想要的文本","您的 toast 弹出窗口的标题");
通过将文本设置为标题、第二组引号并将第一组引号留空,您的文本现在更易于阅读。
Try this:
SpreadsheetApp.getActive().toast(" ","The text you want here");
By keeping the first set of quotes empty, the second set will bold your text and make it easier to read.
Normally the line would be: .toast("Text you want here","The title of your toast popup");
By making your text as the Title, second set of quotes, and leaving the first quotes empty, your text is now easier to read.
您可以尝试将以下代码放入 Manifest 中:
将其放在
元素上方。You can try to put the following code into your Manifest:
Put it above the
<Application>
element.