Android中通过typeface设置字体 textAppearance设置文字外观
来源:互联网 发布:cdr软件 编辑:程序博客网 时间:2024/06/05 05:06
Android系统默认支持三种字体,分别为:“sans”, “serif”, “monospace",除此之外还可以使用其他字体文件(*.ttf)
方法一:XML中使用android默认字体
<!-- 使用默认的sans字体-->
<TextView Android:id="@+id/sans"
Android:text="Hello,World"
Android:typeface="sans"
Android:textSize="20sp" />
<!-- 使用默认的serifs字体-->
<TextView Android:id="@+id/serif"
Android:text="Hello,World"
Android:typeface="serif"
Android:textSize="20sp" />
<!-- 使用默认的monospace字体-->
<TextView Android:id="@+id/monospace"
Android:text="Hello,World"
Android:typeface="monospace"
Android:textSize="20sp" />
方法二:在Android中可以引入其他字体,首先要将字体文件保存在assets/fonts/目录下
1. <!-- 这里没有设定字体,将在Java代码中设定-->
<TextView Android:id="@+id/custom"
Android:text="Hello,World"
Android:textSize="20sp" />
2. java程序中引入其他字体关键代码
//得到TextView控件对象
TextView textView =(TextView)findViewById(R.id.custom);
//将字体文件保存在assets/fonts/目录下,创建Typeface对象
Typeface typeFace =Typeface.createFromAsset(getAssets(),"fonts/HandmadeTypewriter.ttf");
//使用字体
textView.setTypeface(typeFace);
android:textAppearance设置文字外观。如 “?android:attr/textAppearanceLargeInverse”这里引用的是系统自带的一个外观,?表示系统是否有这种外观,否则使用默认的外观。可设置的值如下:textAppearanceButton/textAppearanceInverse/textAppearanceLarge/textAppearanceLargeInverse
- Android中通过typeface设置字体 textAppearance设置文字外观
- android:textAppearance设置文字外观
- Android中通过typeface设置字体
- Android中通过typeface设置字体
- Android中通过Typeface设置字体
- Android中通过typeface设置字体
- Android中通过typeface设置字体
- Android中通过typeface设置字体
- Android中通过typeface设置字体
- Android中通过typeface设置字体
- Android中通过typeface设置字体
- Android中通过typeface设置字体
- Android中通过typeface设置字体
- Android中通过Typeface设置自定义字体
- Android字体Typeface设置
- Android字体Typeface设置
- Android字体Typeface设置
- android 字体TypeFace设置.
- Android工程在Maven环境下打包
- Useful Links
- UML图
- Python3 如何优雅地使用正则表达式(详解七)
- scala入门-04类(class)的使用
- Android中通过typeface设置字体 textAppearance设置文字外观
- 小方法总结
- 通过Canvas的叠加实现Android中环形View的颜色填充动画效果
- linux下对绝对路径和相对路径的理解
- c/c++读写xml 数据
- hdu 5136 Yue Fei's Battle(计数DP)
- TCP连接探测中的Keepalive和心跳包. 关键字: tcp keepalive, 心跳, 保活
- 自定义Dialog
- Vim 打开两三个文件,并且进行对比,或者说同时打开两个界面