如何在Android中常规设置字体粗细 [英] How to set font weight as light, regular in Android

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

问题描述

我有3个文本视图.我需要将其重量设置为轻",常规"和压缩".有人可以帮助我如何在Android中实现这一目标吗?

I have 3 text views. I need to set their weight as Light, Regular and Condensed. Can someone help me on how to achieve this in Android?

推荐答案

TextView 上使用 android:textStyle 设置类似 bold 的文本样式strong>,斜体或正常.

Use android:textStyle on a TextView to set the text style like bold, italic or normal.

以下是带有粗体文本样式的 TextView 的示例:

Here is an example of a TextView with a bold text style:

<TextView
  android:id="@+id/hello_world"
  android:text="hello world"
  android:layout_width="wrap_content"
  android:layout_height="wrap_content"
  android:textStyle="bold"/>

如果要使用浅色或浓缩色,则必须更改字体.您可以这样做:

If you want to use light or condensed, you will have to change your font. You can do it like this:

android:fontFamily="sans-serif-light"

有关字体的更多信息,请参见以下答案

For more information about fonts, please also look at the following answer Valid values for android:fontFamily and what they map to?

这篇关于如何在Android中常规设置字体粗细的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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