1,下载字体包     http://www.3987.com/xiazai/6/fonts/36616.html#down

2.  studio中src\main\创建assets\fonts,存放字体包

3.  两种使用方法:

<1.只是app中某一块需要使用特定的字体:

     TextView tv= (TextView) findViewById(R.id.tv);
Typeface face= Typeface.createFromAsset(getAssets(), "fonts/kaiti.ttf");
tv.setTypeface(face);

<2.整个app字体都要使用特定字体:

这种情况下如果还用第一种方法给每个TextView设置Typeface 就太麻烦了;

这种情况下可用用自定义控件继承,TextView ,在控件中初始化设置TypeView;

package com.example.harvey.frontpagedemo.view;

import android.content.Context;
import android.content.res.AssetManager;
import android.graphics.Typeface;
import android.util.AttributeSet;
import android.widget.TextView; /**
* Created by Harvey on 2016/4/15.
*/
public class CustomFontTextView extends TextView{
public CustomFontTextView(Context context) {
super(context);
init(context);
}
public CustomFontTextView(Context context, AttributeSet attrs) {
super(context, attrs);
init(context);
}
public CustomFontTextView(Context context, AttributeSet attrs, int defStyle) {
super(context, attrs, defStyle);
init(context);
} private void init(Context context) {
AssetManager assetManager= context.getAssets();
Typeface typeface=Typeface.createFromAsset(assetManager, "fonts/kaiti.ttf");//楷体
// Typeface typeface=Typeface.createFromAsset(assetManager, "fonts/shoujin.ttf");//瘦金体
// Typeface typeface=Typeface.createFromAsset(assetManager,"fonts/fangzhengguli.ttf");//方正古隶
// Typeface typeface=Typeface.createFromAsset(assetManager,"fonts/jinglei.ttf");//方正静蕾简体
// Typeface typeface=Typeface.createFromAsset(assetManager,"fonts/pop.ttf");//pop字体
setTypeface(typeface);
} }

4.  字体包不小......

  

app 要求字体使用楷体,使用字体包的更多相关文章

  1. CSS在线字体库,外部字体的引用方法

    目录: 1:CSS家族五大字体 2:360和谷歌外部字体引用方法 3:谷歌外部字体引用方法详解 4:@font-face用法详解 一: {font-family:serif,sans-serif,fa ...

  2. CSS在线字体库,外部字体的引用方法@font-face

    @font-face是CSS3中的一个模块,他主要是把自己定义的Web字体嵌入到你的网页中,随着@font-face模块的出现,我们在Web的开发中使用字体不怕只能使用Web安全字体,你们当中或许有许 ...

  3. Eclipse3.7默认字体修改-找回Courser-New字体

    1.找到jFace并用WinRAR打开之: jFace的具体位置:$Eclipse目录$/plugins/org.eclipse.jface_3.7.0.I20110522-1430.jar,找到后, ...

  4. 移动端rem布局,用户调整手机字体大小或浏览器字体大小后导致页面布局出错问题

    一.用户修改手机字体设置大小,影响App里打开的web页面. 手机字体设置大小,影响App的页面.Android的可以通过webview配置webview.getSettings().setTextZ ...

  5. [css] 浏览器字体和css设置字体之间的关系

    原文链接:http://www.zhangxinxu.com/wordpress/2010/06/%E5%8F%AF%E7%94%A8%E6%80%A7%E4%B9%8B%E6%B5%8F%E8%A7 ...

  6. Delphi中建立指定大小字体和读取该字体点阵信息的函数(转)

    源:Delphi中建立指定大小字体和读取该字体点阵信息的函数 Delphi中建立指定大小字体和读取该字体点阵信息的函数 作者:Thermometer Email:  webmaster@daheng- ...

  7. 系统里有Courier New字体 Eclipse没有这个字体选项

    问题状态: 系统里有Courier New字体 Eclipse没有这个字体选项问题原因: windows(xp)中的系统字体分为"显示"和"隐藏"两种状态,当为 ...

  8. 【纯代码】Swift-自定义PickerView单选(可修改分割线颜色、修改字体大小、修改字体颜色。)(可根据需要自己扩展)

    typealias PopPickerViewCallBackClosure = (_ resultStr:NSString?) -> () class PopPickerView : UIVi ...

  9. Windows环境中,通过Charles工具,抓取安卓手机、苹果手机中APP应用的http、https请求包信息

    Windows环境中,通过Charles工具,抓取安卓手机.苹果手机中APP应用的http.https请求包信息1.抓取安卓手机中APP应用的http请求包信息1)在电脑上操作,查看Windows机器 ...

随机推荐

  1. asp.net中插件开发模式说明

    第一定义接口 /// <summary>          /// 这是插件必须实现的接口,也是主程序与插件通信的唯一接口         /// 换句话说,主程序只认识插件里的这些方法  ...

  2. 树莓派摄像头模块转成H264编码通过RTMP实现Html输出

    官方原帖 http://www.raspberrypi.org/phpBB3/viewtopic.php?f=43&t=45368&sid=b81f6551e478f0f6e172aa ...

  3. 分享45个android实例源码,很好很强大

    分享45个android实例源码,很好很强大 http://www.apkbus.com/android-20978-1-1.html 分享45个android实例源码,很好很强大http://www ...

  4. 【JAVA】【Eclipse】出现This element neither has attached source nor attached Javadoc...的解决方法

    This element neither has attached source nor attached Javadoc and hence no Javadoc could be found Ec ...

  5. PHP中类自动加载的方式

    最近在学习composer,发现从接触PHP到现在已经遇到了三种关于PHP中类的自动加载方式,这其中包括PHP自带的类的自动加载方式.PHP的第三方的依赖管理工具composer的加载方式以及PHP的 ...

  6. sql 时间(datetime)计算

    SELECT *FROM sc_sowu_orderreturnWHERE STATUS = '0'AND submit_time < DATE_ADD(now(), INTERVAL - 4 ...

  7. C语言Notebook

    int *pointer=NULL    /*指针变量一定要赋初值*/pritnf("Pointer' address is:%p",&pointer);  /*打印指针变 ...

  8. python 去掉列表(list)中的所有空元素

    while '' in listExample: listExample.remove('')

  9. git乱码问题解决

    etc\gitconfig文件中增加以下内容: [gui]     encoding = utf-8 [i18n]     commitencoding = gbk [svn]     pathnam ...

  10. Redis3.0.1 Stable版本的集群部署(Mac)

    本文档基于如下原始文档(CentOS)创建: http://blog.csdn.net/xu470438000/article/details/42971091 修改了一些路径的错误,补全了一些命令执 ...