尊重原创:http://blog.csdn.net/yuanzeyao/article/details/40478815

如今非常多应用中喜欢使用自己定义字体,今天我就来实如今TextView中使用自己定义字体。并设置高亮,显示效果例如以下:

watermark/2/text/aHR0cDovL2Jsb2cuY3Nkbi5uZXQveXVhbnpleWFv/font/5a6L5L2T/fontsize/400/fill/I0JBQkFCMA==/dissolve/70/gravity/Center" alt="" />

定义LedTextView.java

/**
* 高亮显示的TextView
* com.led.demo.LedTextView
* @author yuanzeyao <br/>
* create at 2014年10月26日 下午6:46:05
*/
public class LedTextView extends TextView
{
private static final String TAG = "LedTextView"; public LedTextView(Context context)
{
super(context);
init(context);
} public LedTextView(Context context, AttributeSet attrs)
{
super(context, attrs);
init(context);
} public LedTextView(Context context, AttributeSet attrs, int defStyle)
{
super(context, attrs, defStyle);
init(context);
} private void init(Context context)
{
//字体资源放入assets目录中
AssetManager am=context.getAssets();
Typeface font=Typeface.createFromAsset(am, "fonts/digital-7.ttf");
setTypeface(font);
}

在布局文件里引用LedTextView

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:background="@android:color/black"
android:paddingTop="@dimen/activity_vertical_margin"
tools:context=".MainActivity" > <com.led.demo.LedTextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textColor="#00ff00"
android:text="12:00:00"
android:shadowColor="#00ff00"
android:shadowDx="0"
android:shadowDy="0"
android:textSize="20sp"
/> </RelativeLayout>

安装完成,它可以显示上述结果

TextView 使用自定义的字体和亮点的更多相关文章

  1. 自定义TextView 调用ttf格式字体

    自定义TextView 调用ttf格式字体 1.<strong>将ttf格式文件存放在assets/fonts/下</strong> 注:PC系统字体存放在C:\Windows ...

  2. Android怎么使用字体图标 自定义FontTextView字体图标控件-- 使用方法

    首先我想说明一下字体图标的好处,最大的好处就是自适应了,而且是使用TextView 不用去切图,是矢量图 灵活调用 第一步我要说明一下一般字体图标的来源,我这里使用的是  --阿里巴巴矢量图标库 -网 ...

  3. Font Combiner – 自定义网页字体和图标生成工具

    Font Combiner 是一个功能丰富的 Web 字体生成工具和字体改进工具,提供字距调整.构造子集.各种提示选项和自定义字体字形组合.您可以生成您自己的自定义字体的格式和文件大小. 另外还有成千 ...

  4. IconVault – 创建自定义图标字体的神器推荐

    图标字体简单来说就是外观呈现为图标的字体,同时具有矢量图形的特征,在不同的设备上使用图标的时候就不用加载不同尺寸的图片文件,能够减少 HTTP 请求数,提高页面加载速度. IconVault 这款在线 ...

  5. Qt:使用自定义的字体

    Qt:使用自定义的字体 1. 下载字体文件 2. 加载字体文件 3. 使用字体   QFontDatabase::addApplicationFont("XENOTRON.TTF" ...

  6. 自己定义TextView 调用ttf格式字体

    方法一:自己定义TextView 调用ttf格式字体 <strong>将ttf格式文件存放在assets/fonts/下</strong> 注:PC系统字体存放在C:\Wind ...

  7. Android TextView使用HTML处理字体样式、显示图片等

    一般情况下,TextView中的文本都是一个样式.那么如何对于TextView中各个部分的文本来设置字体,大小,颜色,样式,以及超级链接等属性呢?下面我们通过SpannableString的具体实例操 ...

  8. 自定义TextView带有各类.ttf字体的TextView

    最近项目遇到了将普通文字转化为带有字体样式的文字,这里就涉及到了.ttf文件,我上网百度了不少资料最终终于实现了,现在想想其实并不复杂 1,你需要下载一种.ttf字体文件,你可以从网上找到一种字体的. ...

  9. Android自定义TTF字体

    前言: 在Android Design中一个设计手册.在设计手册中有常用的UI图标,图标大小规范等. 其中,有一个TTF字体,以前感觉没什么用.但是我在学习时,常看到有许多开发者使用Google 提供 ...

随机推荐

  1. windows下eclipse跑junit报错:CreateProcess error=206

    from:http://isuifengfei.iteye.com/blog/1684262 windows下,eclipse中运行junit出现错误提示: Exception occurred ex ...

  2. 与众不同 windows phone (19) - Device(设备)之陀螺仪传感器, Motion API

    原文:与众不同 windows phone (19) - Device(设备)之陀螺仪传感器, Motion API [索引页][源码下载] 与众不同 windows phone (19) - Dev ...

  3. 14.4.4 Configuring the Memory Allocator for InnoDB InnoDB 配置内存分配器

    14.4.4 Configuring the Memory Allocator for InnoDB InnoDB 配置内存分配器 当InnoDB 被开发, 内分配齐 提供了与操作系统和运行库往往缺乏 ...

  4. Python的对象和类型

    Python使用对象来存储数据,构造任何类型的值都是一个对象. 任何一个对象都有三个特性:身份,类型和值. 身份是对象的唯一标识,可以通过内建函数id()得到,这个值可以认为是该对象的内存地址. Py ...

  5. Codeforces Round #235 (Div. 2) D. Roman and Numbers (数位dp、状态压缩)

    D. Roman and Numbers time limit per test 4 seconds memory limit per test 512 megabytes input standar ...

  6. js错误 SyntaxError: missing : after property id

    在用jquery的post方法时 $.post('adminCheckTpmisPlans.do',{'test',str},function(f){ ... }) 报如下错误 SyntaxError ...

  7. 《转》 Openstack Grizzly 指定 compute node 创建 instance

    声明:此文档仅仅做学习交流使用,请勿用作其它商业用途 作者:朝阳_tony 邮箱:linzhaolover@gmail.com 2013年6月4日9:37:44 星期二 转载请注明出处:http:// ...

  8. Codeforces Round #350 (Div. 2)解题报告

    codeforces 670A. Holidays 题目链接: http://codeforces.com/contest/670/problem/A 题意: A. Holidays On the p ...

  9. hdu 3488 Tour

    题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=3488 题意:给你一个N个顶点M条边的带权有向图,要你把该图分成1个或多个不相交的有向环.且所有定点都只 ...

  10. ie浏览器提交参数和其它浏览器的区别

    场景描述: 用户注册模块(ajax提交方式,post方法),在url后追加了一个参数,如:url+‘btnvalue=中文参数’,如此在非ie浏览器注册时,功能完好,但在ie下注册不成功.调式后发现在 ...