如何在 Android TextView 中将字体样式设置为粗体、斜体和下划线? [英] How to set the font style to bold, italic and underlined in an Android TextView?

查看:102
本文介绍了如何在 Android TextView 中将字体样式设置为粗体、斜体和下划线?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想让 TextView 的内容变为粗体、斜体和下划线.我尝试了以下代码,它可以工作,但没有下划线.

I want to make a TextView's content bold, italic and underlined. I tried the following code and it works, but doesn't underline.

<Textview android:textStyle="bold|italic" ..

我该怎么做?有什么快速的想法吗?

How do I do it? Any quick ideas?

推荐答案

我不知道下划线,但是粗体和斜体有 "bolditalic".这里没有提到下划线:http://developer.android.com/reference/android/widget/TextView.html#attr_android:textStyle

I don't know about underline, but for bold and italic there is "bolditalic". There is no mention of underline here: http://developer.android.com/reference/android/widget/TextView.html#attr_android:textStyle

请注意,要使用提到的 bolditalic 您需要,我从该页面引用

Mind you that to use the mentioned bolditalic you need to, and I quote from that page

必须是以下常量值中的一个或多个(用|"分隔).

Must be one or more (separated by '|') of the following constant values.

所以你会使用 bold|italic

您可以检查这个问题是否有下划线:我可以在文本中添加下划线吗安卓布局?

You could check this question for underline: Can I underline text in an android layout?

这篇关于如何在 Android TextView 中将字体样式设置为粗体、斜体和下划线?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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