Android学习记录 之 字体
来源:互联网 发布:淘宝规格怎么填写 编辑:程序博客网 时间:2024/05/17 22:27
在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);
0 0
- 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学习之“字体属性”
- CVI 常见错误
- poj 3074 Sudoku(Dancing Links)
- 《linux 内核完全剖析》 include/asm/io.h
- Android Studio Beat版发布!
- 从前有座灵剑山--理想以及狂热(6)
- Android学习记录 之 字体
- 【原创】20大最活跃的敢死队营业部排名
- 【Linux】使用read、write、lseek函数实现文件读写操作
- android中minLines和maxLines的区别
- socket 发送与接收
- 一个TextView多种字体颜色,加超链接
- QT——自定义字符串格式
- ATS插件开发中内存泄露问题的解决方法探讨
- ant安装、环境变量配置及验证