【问题标题】:Android:add helvetica neue font in applicationAndroid:在应用程序中添加 helvetica neue 字体
【发布时间】:2018-10-11 21:09:54
【问题描述】:

我正在制作一个应用程序,我必须在其中使用 helvetica neue 字体作为文本,但问题是我不知道如何在 android 中使用 helvetica 字体。我的问题是 android 是否支持 helvetica 字体,它是的那么如何使用该字体,因为我无法在 windows-preference-general-appreance-color 和 fonts 中找到 helvetica 字体。任何帮助将不胜感激。 谢谢。

【问题讨论】:

  • 您需要在应用程序中包含相应的字体文件 (ttf)。
  • 希望您知道 Helvetica 仅供个人免费使用。

标签: android fonts


【解决方案1】:
place the TTF file in the ./assets directory (create it if it doesn’t exist yet).

然后在你的活动中,

   1. TextView txt = (TextView) findViewById(R.id.custom_font);  
   2. Typeface font = Typeface.createFromAsset(getAssets(), "<font file name>.ttf");  
   3. txt.setTypeface(font);  

更多信息请看:

Using Custom Fonts

Using Custom fonts on Android

How to use external fonts in Android

【讨论】:

    【解决方案2】:

    从 API 级别 26 开始,android 支持直接从项目中添加自定义字体,而无需创建自定义 textview 或 edittext。

    从下面的链接找到它: Fonts in XML

    【讨论】:

      猜你喜欢
      • 2011-12-28
      • 1970-01-01
      • 1970-01-01
      • 2013-08-07
      • 2020-04-08
      • 2015-06-05
      • 1970-01-01
      • 1970-01-01
      • 2011-03-21
      相关资源
      最近更新 更多