Android中字体的处理
来源:互联网 发布:mysql密码忘记了怎么办 编辑:程序博客网 时间:2024/05/17 08:47
1、Android系统默认支持三种Android字体,分别为:"sans", "serif", "monospace"
2、在Android中可以引入其他字体
<TableLayoutxmlns:android="http://schemas.android.com/apk/res/android" android:layout_height="fill_parent" android:layout_width="fill_parent" > <TableRow> <TextView android:layout_marginright="4px" android:text="sans:" android:textsize="20sp" /> <!-- 使用默认的sans字体--> <TextView android:id="@+id/sans" android:text="Hello,World" android:textsize="20sp" android:typeface="sans" /> </TableRow> <TableRow> <TextView android:layout_marginright="4px" android:text="serif:" android:textsize="20sp" /> <!-- 使用默认的serifs字体--> <TextView android:id="@+id/serif" android:text="Hello,World" android:textsize="20sp" android:typeface="serif" /> </TableRow> <TableRow> <TextView android:layout_marginright="4px" android:text="monospace:" android:textsize="20sp" /> <!-- 使用默认的monospace字体--> <TextView android:id="@+id/monospace" android:text="Hello,World" android:textsize="20sp" android:typeface="monospace" /> </TableRow> <!-- 这里没有设定字体,我们将在Java代码中设定--> <TableRow> <TextView android:layout_marginright="4px" android:text="custom:" android:textsize="20sp" /> <TextView android:id="@+id/custom" android:text="Hello,World" android:textsize="20sp" /> </TableRow> </TableLayout>
1、Android系统默认支持三种Android字体,分别为:"sans", "serif", "monospace"
2、在Android中可以引入其他字体
main.xml
<TableLayoutxmlns:android="http://schemas.android.com/apk/res/android" android:layout_height="fill_parent" android:layout_width="fill_parent" > <TableRow> <TextView android:layout_marginright="4px" android:text="sans:" android:textsize="20sp" /> <!-- 使用默认的sans字体--> <TextView android:id="@+id/sans" android:text="Hello,World" android:textsize="20sp" android:typeface="sans" /> </TableRow> <TableRow> <TextView android:layout_marginright="4px" android:text="serif:" android:textsize="20sp" /> <!-- 使用默认的serifs字体--> <TextView android:id="@+id/serif" android:text="Hello,World" android:textsize="20sp" android:typeface="serif" /> </TableRow> <TableRow> <TextView android:layout_marginright="4px" android:text="monospace:" android:textsize="20sp" /> <!-- 使用默认的monospace字体--> <TextView android:id="@+id/monospace" android:text="Hello,World" android:textsize="20sp" android:typeface="monospace" /> </TableRow> <!-- 这里没有设定字体,我们将在Java代码中设定--> <TableRow> <TextView android:layout_marginright="4px" android:text="custom:" android:textsize="20sp" /> <TextView android:id="@+id/custom" android:text="Hello,World" android:textsize="20sp" /> </TableRow> </TableLayout>
FontsActivity.java
packageyyl.fonts; importAndroid.app.Activity;importAndroid.graphics.Typeface;importAndroid.os.Bundle;importAndroid.widget.TextView; publicclassFontsActivity extendsActivity { /** 当activity第一次被创建的时候调用. */ @Override publicvoidonCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); //得到TextView控件对象 TextView textView = (TextView)findViewById(R.id.custom); //将字体文件保存在assets/fonts/目录下,www.android-study.com创建Typeface对象 Typeface typeFace = Typeface.createFromAsset(getAssets(),"fonts/HandmadeTypewriter.ttf"); //应用字体 textView.setTypeface(typeFace); }}
- Android中字体的处理
- Android中字体的处理
- Android中字体的处理
- Android 中字体的处理
- Android 中字体的处理
- Android 中字体的处理
- Android中使用自定义的字体
- Android中Paint字体属性的设置
- android中字体颜色的设置
- Android中使用自定义的字体
- Android中Paint字体属性的设置
- Android中Paint字体属性的设置
- Android中使用自定义的字体
- Android中使用自定义的字体
- Android中字体颜色的设置
- Android 中使用自定义字体的方法
- Android 中使用自定义字体的方法
- Android中Paint字体的使用
- SQL2005 无人值守安装
- 没有后援
- Android 日历提供器(二)
- C++宽字符:从char到wchar_t
- 磁盘分区管理工具
- Android中字体的处理
- 对象拷贝类PropertyUtils,BeanUtils,BeanCopier的技术沉淀(3)------优化方案
- querySelector、querySelectorAll和CSS3 Selectors一起来
- stm32_eval_sdio_sd.c版本4.5的文件头
- 源码下载与编译
- GEA无法运行Python 程序
- CSUOJ优先队列
- phpmpsv2.3编辑模块不显示解决方法
- 使用js实现文本分页显示