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的时候 , 其余字 ...
随机推荐
- Netty源码分析第4章(pipeline)---->第7节: 前章节内容回顾
Netty源码分析第四章: pipeline 第七节: 前章节内容回顾 我们在第一章和第三章中, 遗留了很多有关事件传输的相关逻辑, 这里带大家一一回顾 首先看两个问题: 1.在客户端接入的时候, N ...
- Codeforces1101 | EducationalRound58 | 瞎讲报告
目录 Educational Codeforces Round 58 (Rated for Div. 2) A. Minimum Integer B. Accordion C. Division an ...
- 02-matplotlib-散点图
import numpy as np import matplotlib.pyplot as plt ''' 散点图显示两组数据的值,每个点的坐标位置的值决定 用户观察两种变量的相关性: 正相关 负相 ...
- WinForm中从SQLite数据库获取数据显示到DataGridView
1.关于Sqlite Sqlite是一款开源的.适合在客户端和嵌入式设备中使用的轻量级数据库,支持标准的SQL. 不像SqlServer或Oracle的引擎是一个独立的进程.通过TCP或命名管道等与程 ...
- servlet基础学习总结
Servlet的任务 1. 读取客户端发送的显示的数据,包括HTML表单和一些客户端程序的表单 2. 读取客户端发送的隐式的数据,包括cookies.媒体类型等 3. 处理数据并产生结果 4. ...
- Linux基础入门--01~03
- C++:new&delete
一.new的浅析 在C++中,new主要由三种形式:new operator.operator new和placement new • new operator new operator即一些C++书 ...
- TCP/IP,HTTP,HTTPS,WEBSocket协议
我看看着挺多的,我暂时没时间自己写,有需要的请借鉴 http://mp.weixin.qq.com/s?__biz=MzI0MDQ4MTM5NQ==&mid=2247486927&id ...
- Internet History, Technology and Security (Week6)
Week6 The Internet is desinged based on four-layer model. Each layer builds on the layers below it. ...
- 运行时错误 429,ACTIVEX部件不能创建对象的解决方法小结
错误描述: 发布在IIS上面的网站运行时出现如下错误: Microsoft VBscrīpt 运行时错误 错误 '800a01ad' ActiveX 部件不能创建对象 这个错误是asp组件未注册,而导 ...