具有不同字体和样式的TextView? [英] TextView with different fonts and styles?

查看:60
本文介绍了具有不同字体和样式的TextView?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否可以在同一 TextView 中使用不同大小,字体类型或样式的文本?

Is it possible to have texts with different sizes, font-types or styles in the same TextView ?

类似这样的东西:

| myLogin 注销 |

推荐答案

您可以使用:

textView.setText(Html.fromHtml("<b>myLogin</b> <i>logout</i>"));

有关更多选项,请查看 SpannableString :链接

For more options, look into SpannableString: Link

使用 SpannableString ,您可以将多种格式应用于单个字符串.

With SpannableString, you can apply multiple formatting to a single string.

本文将对您有很大帮助: Android TextView的富格式设置

This article will be very helpful to you: Rich-Style Formatting of an Android TextView

这篇关于具有不同字体和样式的TextView?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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