使 textview 中字符串的第一个单词/字符变大 [英] Making first word/character of string in textview bigger

查看:33
本文介绍了使 textview 中字符串的第一个单词/字符变大的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我一直在网上搜索,但没有找到我可以使用的东西.我的 textview 中有文本,其中包含类似的文本;

I have been searching online but haven't managed to find something that I could use. I have text in my textview that will have text something like;

1 Person
2 Person
3 Person

文本格式如下 (1\nperson), (2\nperson) .... 所以在数字和人物字符串之间添加空格.

the text is formatted like this (1\nperson), (2\nperson) .... so adding space between the number and the person string.

我想做的是让每个字符串的数量更大.例如;

What I want to do is make the number of each string bigger. For example;

我在网上搜索过,但我发现的链接/类似内容并没有那么有用:

I have searched online and the links / similar things I found are not that helpful:

是否可以在一个文件中包含多个样式?文本视图?

具有不同 textSize 的 TextView

textview 的默认字体大小是 15,所以 person 字符串的字体大小总是 15,我想做的是把数字放大,例如字体大小 20.

The default font size for the textview is 15, so the person string font size will always be 15, what I want to do is make the numbers bigger, for example to font size 20.

推荐答案

我认为这可行:

Spannable span = new SpannableString(textView.getText());
span.setSpan(new RelativeSizeSpan(1.5f), 0, 1, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
textView.setText(span);

这篇关于使 textview 中字符串的第一个单词/字符变大的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆