如何设置TextView textStyle,例如粗体,斜体 [英] How to set TextView textStyle such as bold, italic

查看:179
本文介绍了如何设置TextView textStyle,例如粗体,斜体的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何在Java中设置TextView样式(粗体或斜体)而不使用XML布局?

How to set TextView style (bold or italic) within Java and without using the XML layout?

换句话说,我需要用Java编写android:textStyle.

In other words, I need to write android:textStyle with Java.

推荐答案

textView.setTypeface(null, Typeface.BOLD_ITALIC);
textView.setTypeface(null, Typeface.BOLD);
textView.setTypeface(null, Typeface.ITALIC);
textView.setTypeface(null, Typeface.NORMAL);

保留以前的字体

textView.setTypeface(textView.getTypeface(), Typeface.BOLD_ITALIC)

这篇关于如何设置TextView textStyle,例如粗体,斜体的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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