更改TextView的字体? [英] Change TextView Font?
本文介绍了更改TextView的字体?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我如何可以改变字体类型在Android中的TextView?
<的TextView
机器人:layout_width =FILL_PARENT
机器人:layout_height =WRAP_CONTENT
机器人:文本=欢迎光临!
机器人:TEXTSIZE =20SP/>
解决方案
您可以使用的 安卓字体
属性。例如:
<的TextView
机器人:layout_width =FILL_PARENT
机器人:layout_height =WRAP_CONTENT
机器人:文本=欢迎光临!
机器人:字体=SANS
机器人:TEXTSIZE =20SP/>
XML属性只允许值正常
, SANS
,衬线
和等宽
。如果你想使用一个不同的字样
(可能是一个自定义的,你随您的应用程序),则必须通过调用<一个做到这一点在code href="http://developer.android.com/reference/android/widget/TextView.html#setTypeface%28android.graphics.Typeface%29"相对=nofollow> setTypeface()
以加载TextView的后视图。
How can I change font type in Android TextView?
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="Welcome!"
android:textSize="20sp" />
解决方案
You can use the android:typeface
attribute. For example:
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="Welcome!"
android:typeface="sans"
android:textSize="20sp" />
The XML attribute only allows the values normal
, sans
, serif
, and monospace
. If you want to use a different Typeface
(perhaps a custom one that you ship with your app), you will have to do it in code by calling setTypeface()
for the view after the TextView is loaded.
这篇关于更改TextView的字体?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文