把字体在android系统动态地的TextView [英] Put typeface to textview in android dynamically

查看:212
本文介绍了把字体在android系统动态地的TextView的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是新来的机器人。我有一个TextView,并希望自定义字体分配给它。我的字体文件(* .TTF)是在服务器上。我不得不使用code这个文件设置字体动态(飞)。我不想把文件中的资源文件夹或文件夹的原料。这怎么可能实现?


解决方案

  1. 从服务器下载字体

  2. 保存到SD卡

  3. 使用<一个href=\"http://developer.android.com/reference/android/graphics/Typeface.html#createFromFile%28java.lang.String%29\"相对=nofollow> Typeface.createFromFile(字符串路径)

  4. textView.setTypeface(yourTypeface);

I am new to android. I have a textview and want to assign custom font to it. My font file (*.ttf) is on the server. I have to use that file in code to set font dynamically (on the fly). I don't want to put the file in asset folder or any raw folder. How can this be implemented?

解决方案

  1. Download font from server
  2. Save to SD card
  3. Use Typeface.createFromFile(String path)
  4. textView.setTypeface(yourTypeface);

这篇关于把字体在android系统动态地的TextView的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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