【问题标题】:How to use custom fonts in an android application? [closed]如何在 Android 应用程序中使用自定义字体? [关闭]
【发布时间】:2012-09-27 05:06:14
【问题描述】:

我想在 android 应用程序中使用新的自定义字体。解释时请准确具体,我是新手。也就是说,我想让我的 android 应用程序使用这些新的 android 自定义字体http://developer.android.com/design/style/typography.html。谢谢你。请帮忙。

【问题讨论】:

  • Duplicate。对于谁回答,你们应该在询问之前标记重复以鼓励新手搜索。 SO上有很多类似的问题。
  • 这应该作为一个骗子被关闭,而不是“不是一个真正的问题”

标签: android user-interface fonts


【解决方案1】:

试试这个链接here 和here

.ttf 文件用于将不同的格式导入我们的 android 应用程序。 这是处理 .ttf 文件的简单方法。您唯一需要得到的是通过谷歌搜索获取所有可用的 .ttf 文件

【讨论】:

    【解决方案2】:

    您只需将字体 .ttf 文件放在资产文件夹中,并将其分配给文本字段或您想在主要活动中应用的任何内容,如下所示:

    TextView txt = (TextView) findViewById(R.id.custom_font);  
    Typeface font = Typeface.createFromAsset(getAssets(), "Chantelli_Antiqua.ttf");  
    txt.setTypeface(font);  
    

    这里有一个很棒的教程,它将教你所有你需要知道的: http://mobile.tutsplus.com/tutorials/android/customize-android-fonts/

    【讨论】:

      【解决方案3】:

      我们可以通过这种方式使用自定义字体,

      TextView txt = (TextView) findViewById(R.id.custom_font);  
      Typeface font = Typeface.createFromAsset(getAssets(), "Chantelli_Antiqua.ttf");  
      txt.setTypeface(font);  
      

      请参阅此tutorial 以获取完整知识。

      【讨论】:

      • 除了代码之外还有其他方法可以在布局xml文件中执行吗?
      • 我不认为我们可以使用 xml 布局来做到这一点,而简单的方法就是通过编码
      • 感谢 Aerrow、Sharath 和 Anup
      • @ejobity: 也参考这个.. stackoverflow.com/questions/2376250/…
      猜你喜欢
      • 2013-05-12
      • 2011-03-31
      • 2015-02-25
      • 1970-01-01
      • 2012-08-04
      • 2018-05-29
      • 1970-01-01
      • 2016-04-11
      • 2020-12-05
      相关资源
      最近更新 更多