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:textAppearance设置文字外观。如“?android:attr/textAppearanceLargeInverse ”这里引用的是系统自带的一个外观,?表示系统是否有这种外观,否则使用默认的外观。可设置的值如下:...
自学 Android 做的第二十五个 Android 程序,使用了 TypeFace
我们可以在程序中放入ttf字体文件,在程序中使用Typeface设置字体。 第一步,在assets目录下新建fonts目录,把ttf字体文件放到这。 第二步,程序中调用: 代码如下:AssetManager mgr=getAssets();//得到...
Android Typeface Helper,可以帮你轻松实现自定义字体的库,博客附件,效果请查看博客相对应项目。
Android lacks proper support for custom typefaces. Most obvious method of defining typeface for UI elements via XML attributes is missing from default framework views. This library makes it a lot ...
我们可以在程序中放入ttf字体文件,在程序中使用Typeface设置字体。 第一步,在assets目录下新建fonts目录,把ttf字体文件放到这。 第二步,程序中调用: AssetManager mgr=getAssets();//得到AssetMa
给TextView设置字体样式的三种方法
TypefaceHelper, helper 对象,用于将字体注入到android的各种文本视图中 TypefaceHelper helper 对象,用于将字体注入到android的各种文本视图中。概述我们可以以为任何文本视图使用各种自定义字体资产,但是没有...
在Android SDK中使用Typeface类来定义字体,可以通过常用字体类型名称进行设置,如设置默认黑体: Paint mp = new paint(); mp.setTypeface(Typeface.DEFAULT_BOLD) 常用的字体类型名称还有: * Typeface.DEFAULT /...
字体文本视图字体 TextView 允许您直接在 XML 中指定自定义字体,并避免创建字体样板代码。注意此库已弃用且不再维护。 请利用精彩的库来满足您所有的自定义字体需求。快速开始第 1 步 - 添加字体 TextView 作为库...
Typeface字体是一款用于时尚
android 系统本身内置了一些字体,可以在程序中使用,并且支持在xml配置textView的时候进行修改字体的样式。支持字段为android:textStyle ,android:typeface, android:fontFamily,系统内置了normal|bold|italic三种...
MISO-typeface
灰烬字体 ... 从字体中选择一个字体并将其添加到您的项目中: npm install typeface-lato --save-dev 而已! 您现在可以在应用程序的样式中自由使用font-family: "Lato" 。 高级用法 Ember字体将尝试
通过findViewById找到view,然后一个个的去设置字体 Typeface customFont = Typeface.createFromAsset(this.getAssets(), "fonts/customFont.ttf"); TextView view = (TextView) findViewById(R.id.text); view....
Android 开发人员为 TextViews 设置字体样式的简单方法 这个开发小片段应该可以帮助开发者为 TextView/TextViews 设置字体,并且减轻总是试图调用Typeface.createFromAsset(....);的压力Typeface.createFromAsset(.....
Android实现新字体的引入(Typeface的使用)-附件资源