Android学习记录 之 字体
来源:互联网 发布:重建期初数据 编辑:程序博客网 时间:2024/05/21 07:57
在android系统中,自带的只有三种字体---"sans","serif"和"monospace",你只要在xml文件中的
Xml代码
- android:typeface
Xml代码
- <TableLayout
- xmlns:android="http://schemas.android.com/apk/res/android"
- android:layout_width="fill_parent"
- android:layout_height="fill_parent"
- android:stretchColumns="1">
- <TableRow>
- <TextView
- android:text="sans:"
- android:layout_marginRight="4px"
- android:textSize="20sp"
- />
- <TextView
- android:id="@+id/sans"
- android:text="Hello, world!"
- android:typeface="sans"
- android:textSize="20sp"
- />
- </TableRow>
- <TableRow>
- <TextView
- android:text="serif:"
- android:layout_marginRight="4px"
- android:textSize="20sp"
- />
- <TextView
- android:id="@+id/serif"
- android:text="Hello, world!"
- android:typeface="serif"
- android:textSize="20sp"
- />
- </TableRow>
- <TableRow>
- <TextView
- android:text="monospace:"
- android:layout_marginRight="4px"
- android:textSize="20sp"
- />
- <TextView
- android:id="@+id/monospace"
- android:text="Hello, world!"
- android:typeface="monospace"
- android:textSize="20sp"
- />
- </TableRow>
- <TableRow>
- <TextView
- android:text="Custom:"
- android:layout_marginRight="4px"
- android:textSize="20sp"
- />
- <TextView
- android:id="@+id/custom"
- android:text="Hello, world!"
- android:textSize="20sp"
- />
- </TableRow>
- </TableLayout>
有时候,系统自带的字体并不能满足我们特殊的需求,这时候就需要引用其他的字体了,可以把下载的字体文件放在assets目录下.自定义字体文件不能使用xml代码读取而应该使用java代码:
Java代码
- public class Test extends Activity {
- @Override
- public void onCreate(Bundle icicle) {
- super.onCreate(icicle);
- Android学习记录 之 字体
- Android学习记录 之 字体
- GDI+学习记录之遍历系统中所有字体系列
- Android 学习记录 之 notification
- 记录Android学习之路
- Android学习记录之(一)
- CSS学习之 字体
- 记录我的android学习之路
- Android学习记录之Volley框架JSONObjectRequest
- Android 学习记录之requestWindowFeature属性解析
- Android 学习记录之equestWindowFeature简介
- Android控件之TextView学习记录
- android 多媒体之 MediaStore 学习记录
- android 学习记录之——Activity
- GDI+学习记录(16)-字体Font
- Qt-学习记录03-编码、国际化、字体
- Android菜鸟之学习android源码之四(修改系统默认字体尺寸)
- CSS学习之“字体属性”
- android-Excel表的操作 - 随心
- ActiveX Controls
- OpenGL ES 1.0官方在线帮助文档
- struts2配置包范围的国际化资源文件
- SOCKADDR_IN
- Android学习记录 之 字体
- 国嵌6410的代码注释
- 【转】vs2008每次build都会重新编译链接,浪费大量时间。
- ++i和i++
- C++Builder之Edit和Memo
- android计算器
- 运算符的优先级
- apache+mysql+php配置
- 黑马程序员-day24综合练习