Android LED数字/电子表字体digital font
来源:互联网 发布:酷狗mac添加音乐 编辑:程序博客网 时间:2024/05/16 13:07
Android LED数字/电子表字体digital font
先看实现的字体样式:
这种类型的字体样式会被一些UI设计用于Android APP中视频,或者广告的倒计时牌,比如常见的Android视频直播软件中右上角的广告倒计时。
实现这种字体样式,先导入一个字体包:digital-7.ttf。这个digital-7.ttf文件,我已经上传,下载链接地址:http://download.csdn.net/download/zhangphil/9965392
拿到digital-7.ttf文件后,作为Android assets资源文件导入,如图:
然后就可以使用了,我给出一个例子,重写一个TextView,PhilText.java:
package zhangphil.app;import android.content.Context;import android.content.res.AssetManager;import android.graphics.Typeface;import android.util.AttributeSet;import android.widget.TextView;import java.io.File;/** * Created by Phil on 2017/9/5. */public class PhilText extends TextView{ public PhilText(Context context, AttributeSet attrs) { super(context, attrs); init(context); } private void init(Context context) { String file = "fonts" + File.separator + "digital-7.ttf"; AssetManager assets = context.getAssets(); Typeface font = Typeface.createFromAsset(assets, file); setTypeface(font); }}
把PhilText直接作为View放到xml布局里面使用:
<?xml version="1.0" encoding="utf-8"?><LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="horizontal"> <TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="倒计时:" /> <zhangphil.app.PhilText android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_marginLeft="10dp" android:text="20" android:textColor="@android:color/holo_green_dark" android:textSize="80dp" android:textStyle="bold" /> <TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="天" /> <zhangphil.app.PhilText android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_marginLeft="10dp" android:text="48" android:textColor="@android:color/holo_green_dark" android:textSize="80dp" android:textStyle="bold" /> <TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="小时" /> <zhangphil.app.PhilText android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_marginLeft="10dp" android:text="09" android:textColor="@android:color/holo_green_dark" android:textSize="80dp" android:textStyle="bold" /> <TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="分" /> <zhangphil.app.PhilText android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_marginLeft="10dp" android:text="05" android:textColor="@android:color/holo_green_dark" android:textSize="80dp" android:textStyle="bold" /> <TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="秒" /></LinearLayout>
代码运行结果就是本文前述的配图。
阅读全文
0 0
- Android LED数字/电子表字体digital font
- android设置字体为LED数字样式
- Android字体Font相关知识
- Android中字体设置Font
- font字体
- Font字体
- Font字体
- Font---Android中字体颜色的设置 .
- android使用Font Awesome字体图标
- Android调用font-awesome字体图标
- android 使用字体图标(Icon Font)
- android使用icon font字体代替图片
- Android实现LED数字显示
- 电子表
- 电子表
- Android - Android Studio修改字体(font)大小(size)
- Android-Android Studio修改字体(font)大小(size)
- 字体Font的使用
- Windows下进入到docker容器镜像内部
- 滑动接听慢卡顿分析
- MAVEN包管理工具
- 数据库锁表的分析与解决(三)
- linux xz格式解压
- Android LED数字/电子表字体digital font
- Maven详解
- PyCharm安装第三方模块Request、BeautifulSoup
- node-red学习第三篇-firstflow
- 【css布局】display、position、float、overflow
- 分布式
- Linux 命令行
- springboot项目的打包部署(gralde和maven)
- Could not create the view: An unexpected exception was thrown.问题解决