【问题标题】:How to set Font for TextView in android? [duplicate]如何在 android 中为 TextView 设置字体? [复制]
【发布时间】:2011-09-10 09:55:27
【问题描述】:

可能重复:
how to change the font on the text view in android?

我在我的应用程序中尝试了很多设置 TextView 的字体。但是似乎没有办法在android中设置字体。我想通过 xml 为我的所有 TextView 设置 Arial 字体。我将 Arial.ttf 添加到我的资产中,但仍然无法在 xml 中设置样式。请给我找个出路。

【问题讨论】:

标签: android android-layout


【解决方案1】:

AFAIK 你不能在 xml 中做到这一点,你必须在代码中做到这一点:

Typeface tf = Typeface.createFromAsset(getAssets(),
            "fonts/Arial.otf");
TextView tv = (TextView) findViewById(R.id.CustomFontText);
tv.setTypeface(tf)

【讨论】:

  • 谢谢各位……我搞定了……
猜你喜欢
  • 2018-02-10
  • 1970-01-01
  • 1970-01-01
  • 2013-02-13
  • 2019-10-22
  • 2023-03-29
  • 1970-01-01
  • 1970-01-01
  • 2023-03-07
相关资源
最近更新 更多