app 要求字体使用楷体,使用字体包
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 要求字体使用楷体,使用字体包的更多相关文章
- CSS在线字体库,外部字体的引用方法
目录: 1:CSS家族五大字体 2:360和谷歌外部字体引用方法 3:谷歌外部字体引用方法详解 4:@font-face用法详解 一: {font-family:serif,sans-serif,fa ...
- CSS在线字体库,外部字体的引用方法@font-face
@font-face是CSS3中的一个模块,他主要是把自己定义的Web字体嵌入到你的网页中,随着@font-face模块的出现,我们在Web的开发中使用字体不怕只能使用Web安全字体,你们当中或许有许 ...
- Eclipse3.7默认字体修改-找回Courser-New字体
1.找到jFace并用WinRAR打开之: jFace的具体位置:$Eclipse目录$/plugins/org.eclipse.jface_3.7.0.I20110522-1430.jar,找到后, ...
- 移动端rem布局,用户调整手机字体大小或浏览器字体大小后导致页面布局出错问题
一.用户修改手机字体设置大小,影响App里打开的web页面. 手机字体设置大小,影响App的页面.Android的可以通过webview配置webview.getSettings().setTextZ ...
- [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 ...
- Delphi中建立指定大小字体和读取该字体点阵信息的函数(转)
源:Delphi中建立指定大小字体和读取该字体点阵信息的函数 Delphi中建立指定大小字体和读取该字体点阵信息的函数 作者:Thermometer Email: webmaster@daheng- ...
- 系统里有Courier New字体 Eclipse没有这个字体选项
问题状态: 系统里有Courier New字体 Eclipse没有这个字体选项问题原因: windows(xp)中的系统字体分为"显示"和"隐藏"两种状态,当为 ...
- 【纯代码】Swift-自定义PickerView单选(可修改分割线颜色、修改字体大小、修改字体颜色。)(可根据需要自己扩展)
typealias PopPickerViewCallBackClosure = (_ resultStr:NSString?) -> () class PopPickerView : UIVi ...
- Windows环境中,通过Charles工具,抓取安卓手机、苹果手机中APP应用的http、https请求包信息
Windows环境中,通过Charles工具,抓取安卓手机.苹果手机中APP应用的http.https请求包信息1.抓取安卓手机中APP应用的http请求包信息1)在电脑上操作,查看Windows机器 ...
随机推荐
- HttpContextBase转换成HttpContext对象
有以下方法: 主要是方式就是通过context获取HttpApplication,然后通过Application获取相应的HttpContext ①HttpContext context=HttpCo ...
- MVVM模式下弹出窗体
原地址:http://www.cnblogs.com/yk250/p/5773425.html 在mvvm模式下弹出窗体,有使用接口模式传入参数new一个对象的,还有的是继承于一个window,然后在 ...
- 十一、Manipulators
1. Manipulators是可以用三维进行绘制的的节点,可以将用户行为值化,对其他节点的属性进行modify. 2. 属性值可以通过Channel Box 和Graph Editor进行修改.同其 ...
- Linux 权限设置
一.文件和目录权限 在Linux系统中,用户可以对每一个文件或目录都具有访问权限,这些访问权限决定了谁能访问,以及如何访问这些文件和目录. 1.文件权限简介 在Linux系统中,每一位用户都有对文件或 ...
- SQL语句的增删查改
一.增:有2种方法 1.使用insert插入单行数据: 语法:insert [into] <表名> [列名] values <列值> 例:insert into Strdent ...
- Java反射机制DOME
Java反射机制 public class TestHibernate { @Test public void TestHb(){ try { Class cs = Class.forName(&qu ...
- 分享45个android实例源码,很好很强大
分享45个android实例源码,很好很强大 http://www.apkbus.com/android-20978-1-1.html 分享45个android实例源码,很好很强大http://www ...
- 分拆素数和 HDU - 2098
把一个偶数拆成两个不同素数的和,有几种拆法呢? Input输入包含一些正的偶数,其值不会超过10000,个数不会超过500,若遇0,则结束.Output对应每个偶数,输出其拆成不同素数的个数,每个结果 ...
- for 小曦
安装GO 当前版本1.6.2 http://blog.163.com/hehaifeng1984@126/blog/static/690011362013101044011568/ 教程 https: ...
- promise实例小球运动
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8&quo ...