标签:
1.android Typeface使用TTF字体文件设置字体
我们可以在程序中放入ttf字体文件,在程序中使用Typeface设置字体。
第一步,在assets目录下新建fonts目录,把ttf字体文件放到这。
第二步,程序中调用:
|
1
2
3
4
5
6
7
|
AssetManager mgr=getAssets();//得到AssetManagerTypeface tf=Typeface.createFromAsset(mgr, "fonts/ttf.ttf");//根据路径得到Typefacetv=findViewById(R.id.textview);tv.setTypeface(tf);//设置字体 |
2.在xml文件中使用android:textStyle=”bold” 可以将英文设置成粗体, 但是不能将中文设置成粗体,
将中文设置成粗体的方法是:
|
1
2
|
TextView tv = (TextView)findViewById(R.id.TextView01); tv.getPaint().setFakeBoldText(true);//中文仿“粗体”--使用TextPaint的仿“粗体”设置setFakeBoldText为true。 |
自从Android4.0后默认字体就使用了Roboto,下面介绍一下使用方法:
|
1
2
3
4
5
6
|
android:fontFamily="sans-serif" // roboto regularandroid:fontFamily="sans-serif-light" // roboto lightandroid:fontFamily="sans-serif-condensed" // roboto condensedandroid:fontFamily="sans-serif-thin" // roboto thin (android 4.2)//in combination withandroid:textStyle="normal|bold|italic" |
可用的参数:
Regular
Italic
Bold
Bold-italic
Light
Light-italic
Thin
Thin-italic
Condensed regular
Condensed italic
Condensed bold
Condensed bold-italic
结伴旅游,一个免费的交友网站:www.jieberu.com
推推族,免费得门票,游景区:www.tuituizu.com
标签:
原文地址:http://www.cnblogs.com/rabbit-bunny/p/4229235.html