LED时钟显示
来源:互联网 发布:天猫网络异常 编辑:程序博客网 时间:2024/05/16 01:51
类似于LED 时钟的样式, 字体设置通过ttf设置,ttf为字体格式
1.新建assets文件夹,文件夹的的位置必须是和res平级
2.新建LedTextView 设置字体
public class LEDTextView extends TextView { private static final String FONTS_FOLDER = "fonts"; private static final String FONT_DIGITAL_7 = FONTS_FOLDER + File.separator + "digital-7.ttf"; 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) { AssetManager assets = context.getAssets(); final Typeface font = Typeface.createFromAsset(assets, FONT_DIGITAL_7); setTypeface(font); }}
3.布局文件
<com.ddswez.lpf.myapplication.hack.hack11.LEDTextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_centerInParent="true" android:text="88:88:88" android:textColor="#33ff0000" android:textSize="80sp" /><com.ddswez.lpf.myapplication.hack.hack11.LEDTextView android:id="@+id/main_clock_time" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_centerInParent="true" android:shadowColor="#ff0000" android:shadowDx="0" android:shadowDy="0" android:shadowRadius="10" android:textColor="#ff0000" android:textSize="80sp" />
修改shadowDx shadowDy 属性的值可以改变阴影与文本之间的偏移,指定android:shadowRadius属性可以产生一种文本更亮的错觉.
4.时钟跳动的代码就是一个handler获取当前时间循环调用
private final Runnable mTimeRefresher = new Runnable() { @Override public void run() { final Date d = new Date(); mTextView.setText(String.format(DATE_FORMAT, d.getHours(), d.getMinutes(), d.getSeconds())); mHandler.postDelayed(this, REFRESH_DELAY); }};
显示效果
0 0
- LED时钟显示
- LED数字时钟
- 简单的LED时钟控件
- 时钟程序(LED+DS1302+AT89S52)
- 时钟显示
- 显示时钟
- 显示时钟
- 使用C#编写LED样式时钟控件
- 使用C#编写LED样式时钟控件
- 使用C#编写LED样式时钟控件
- 7219芯片驱动LED的电子时钟
- 使用CANVAS绘制LED点阵时钟
- LED显示时间
- 1602LED显示
- 1602LED显示(2)
- LED数码管的显示
- LED点阵书写显示
- LED显示模块
- pthread_join函数
- 关于软件文档 这些你知道吗?
- Scrapy的几个命令行命令
- Java并发编程总结4——ConcurrentHashMap在jdk1.8中的改进
- iOS 【UIKit-导航控制器 UINavigationController】
- LED时钟显示
- 购物车模块测试
- seedlab:return-to-libc
- [不错]AI是什么 将带我们去哪儿?
- 关于try catch finally 中的return问题
- ios学习路线—Objective-C(nil与release的区别与用法)
- python set
- ubuntu samba服务器的安装和出错修改
- 常用DOS命令祥解