Android字体设置
// 自定义字体
custom = new TextView(this);
//xx.ttf located at assets/fonts/
typeface = Typeface.createFromAsset(getAssets(),"fonts/xx.ttf");
custom.setTypeface(typeface);
.自定义字体
1.android Typeface使用TTF字体文件设置字体
我们可以在程序中放入ttf字体文件,在程序中使用Typeface设置字体。
第一步,在assets目录下新建fonts目录,把ttf字体文件放到这。
第二步,程序中调用:
AssetManager mgr=getAssets();//得到AssetManager
Typeface tf=Typeface.createFromAsset(mgr, "fonts/ttf.ttf");//根据路径得到Typeface
tv.setTypeface(tf);//设置字体
2.在xml文件中使用android:textStyle=”bold” 可以将英文设置成粗体,  但是不能将中文设置成粗体, 
将中文设置成粗体的方法是: 
TextView tv = (TextView)findViewById(R.id.TextView01); 
 tv.getPaint().setFakeBoldText(true);//中文仿“粗体”--使用TextPaint的仿“粗体”设置setFakeBoldText为true。
参考:
http://hi.baidu.com/spare_h/blog/item/490fa14d24325ce0d62afc34.html
http://hi.baidu.com/spare_h/blog/item/a8a20818cfde325c42a9ad49.html
xml 中 android:fontFamily 的用法
From android 4.1 / 4.2, the following Roboto font families are available:
android:fontFamily="sans-serif" // roboto regular
android:fontFamily="sans-serif-light"     // roboto light
android:fontFamily="sans-serif-condensed" // roboto condensed
android:fontFamily="sans-serif-thin"      // roboto thin (android 4.2)
in combination with
android:textStyle="normal|bold|italic"
this 12 variants are possible:
Regular
Italic
Bold
Bold-italic
Light
Light-italic
Thin
Thin-italic
Condensed regular
Condensed italic
Condensed bold
Condensed bold-italic
android:fontFamily 与 android:typeface 相同
Android内建的字体有:
normal
sans
serif
monospace
详见:TextView | Android Developers
http://developer.android.com/reference/android/widget/TextView.html#attr_android%3atypeface
How to change fontFamily of TextView in Android - Stack Overflow
http://stackoverflow.com/questions/12128331/how-to-change-fontfamily-of-textview-in-android
Android System Fonts(/system/fonts):
AndroidClock.ttf
AndroidClock_Highlight.ttf
AndroidClock_Solid.ttf
AndroidEmoji.ttf
Clockopia.ttf
DroidNaskh-Regular.ttf
DroidNaskhUI-Regular.ttf
DroidSans-Bold.ttf
DroidSans.ttf
DroidSansArmenian.ttf
DroidSansEthiopic-Regular.ttf
DroidSansFallback.ttf
DroidSansGeorgian.ttf
DroidSansHebrew-Bold.ttf
DroidSansHebrew-Regular.ttf
DroidSansMono.ttf
DroidSerif-Bold.ttf
DroidSerif-BoldItalic.ttf
DroidSerif-Italic.ttf
DroidSerif-Regular.ttf
MTLmr3m.ttf
Roboto-Bold.ttf
Roboto-BoldItalic.ttf
Roboto-Italic.ttf
Roboto-Light.ttf
Roboto-LightItalic.ttf
Roboto-Regular.ttf
Roboto-Thin.ttf
Roboto-ThinItalic.ttf
RobotoCondensed-Bold.ttf
RobotoCondensed-BoldItalic.ttf
RobotoCondensed-Italic.ttf
RobotoCondensed-Regular.ttf
Android字体设置的更多相关文章
- Android 字体设置-Typeface讲解
		
控件的字体设置的两种方式 常用的字体类型名称还有: Typeface.DEFAULT //常规字体类型 Typeface.DEFAULT_BOLD //黑体字体类型 Typeface.MONOSPAC ...
 - Android 字体设置
		
Android 对中文字体支持很不好~~ 需要加入相应的字体库 (1)创建布局Layout //创建线性布局 LinearLayout linearLayout=newLinearLayout(thi ...
 - Android字体设置,Roboto字体使用
		
一.自定义字体 1.android Typeface使用TTF字体文件设置字体 我们可以在程序中放入ttf字体文件,在程序中使用Typeface设置字体.第一步,在assets目录下新建fonts目录 ...
 - android ADT 设置编辑字体
		
新配置的android ADT 设置编辑字体的时候 可能里面没有我们想要的Courier new 这种舒服的字体 那么就在 字体选项窗口的 做下端 有个显示更多字体的链接 然后就显示微软的所有字 ...
 - Android开发之字体设置
		
默认字体 Android SDK自带了四种字体:"normal"“monospace",“sans”, “serif”,如下: 字体 看这四兄弟长的还是蛮像,我是看不 ...
 - Android Studio设置自定义字体
		
Android Studio设置自定义字体 (1)进入设置页面,File->Settings (2)自定义字体Editor->Colors&Fonts->Font (3)点击 ...
 - [Android] 字体使用dp单位避免设置系统字体大小对排版的影响
		
[Android] 字体使用dp单位避免设置系统字体大小对排版的影响 以魄族mx3为例,在设置->显示->字体大小中能够选择字号大小例如以下图: 图1. 魄族mx3 会导致软件在有固定定高 ...
 - 【转】Android中设置TextView的颜色setTextColor--代码中设置字体颜色
		
原文网址:http://www.cnblogs.com/myphoebe/archive/2012/01/06/2314728.html android中设置TextView的颜色有方法setText ...
 - android TextView字体设置最少占多少行. 及其 Java String 字符串操作 . .
		
① 字体设置: 修改代码 : GridViewActivity.java priceTv为 TextView priceTv.setMaxLines(3); //当多与7个字fu的时候 , 其余字 ...
 
随机推荐
- centos 开机自启设定:
			
在sentos系统下,主要有两种方法设置自己安装的程序开机启动.1.把启动程序的命令添加到/etc/rc.d/rc.local文件中,比如下面的是设置开机启动httpd. #!/bin/sh # # ...
 - linux安装配置JDK脚本
			
#!/bin/bash # install jdk and configuring environment variables function installjdk(){ tar -zxf jdk- ...
 - 机器学习基础 --- numpy的基本使用
			
一.numpy的简介 numpy是Python的一种开源的数值计算扩展库.这种工具可用来存储和处理大型矩阵,比Python自身的嵌套列表(nested list structure)结构要高效的多(该 ...
 - 对React children 的深入理解
			
React的核心为组件.你可以像嵌套HTML标签一样嵌套使用这些组件,这使得编写JSX更加容易因为它类似于标记语言. 当我刚开始学习React时,当时我认为“使用 props.children 就这么 ...
 - R语言安装R package的2种方法
			
http://www.cnblogs.com/emanlee/archive/2012/12/05/2803606.html
 - Laravel路由除了根目录全报404错误
			
Route::get('hello',function(){ return 'Hello World!'; }); 在laravel/app/Http/routes.php下添加上面的语句,然后再浏览 ...
 - DataRow对象的RowState和DataRowVersion属性特点
			
DataRow对象有两个比较重要的属性,分别是行状态(RowState)和行版本(DataRowVersion),通过这两个属性能够有效的管理表中的行.下面简要的介绍一下行状态和行版本的特点和关系. ...
 - Alpha版本BUG BASH
			
在本次软件开发的第一轮迭代中,我们团队遇到了很多问题.首先是和学长联系不上导致拿到项目前一版本的代码的时间延后了一个星期. 拿到代码后发现由于安装环境的问题代码无法移植.在这一阶段我们就耗费了大量的时 ...
 - 20135316王剑桥 linux第三周课实验笔记
			
通过使用标准的字符码能够对文档中的字母和符号进行编码. 三种重要的数字表现形式: 1. 无符号数:编码基于传统的二进制表示法表示大于或等于零的数字. 2. 补码:编码是表示有符号整数的最常见方法,可以 ...
 - 给定一个十进制的正整数,写下从1开始,到N的所有整数,然后数一下其中出现“1”的个数。
			
一.题目: n给定一个十进制的正整数,写下从1开始,到N的所有整数,然后数一下其中出现“1”的个数. n要求: n写一个函数 f(N) ,返回1 到 N 之间出现的 “1”的个数.例如 f(12) ...