Android开发中如何让你的TextView有跑马灯效果?
来源:互联网 发布:海盗船水冷控制软件 编辑:程序博客网 时间:2024/06/01 08:08
简介
最近下载了一个“国务院”的App,看了首页TextView有跑马灯的效果,这该怎么实现呢?
问题解决
你有没有注意到这样一个东西,你自定义一个Button控件,Button里有一个属性叫ellipsize,译为“省略”,里面有一个“marquee”就是我们所说的跑马灯效果,同样,TextView中也有这个属性,可就是跑不起来,原因是TextView没有获得焦点而Button是有获得焦点的,所以,我们自定义一个TextView就可以让文字有跑马灯这个效果,代码如下:
public class FocusTextView extends TextView { public FocusTextView(Context context) { super(context); } public FocusTextView(Context context, AttributeSet attrs) { super(context, attrs); } public FocusTextView(Context context, AttributeSet attrs, int defStyle) { super(context, attrs, defStyle); } @Override @ExportedProperty(category = "focus") public boolean isFocused() { return true; }}
很简单吧~
0 0
- Android开发中如何让你的TextView有跑马灯效果?
- 【Android 开发】TextView的跑马灯效果
- Android 如何实现TextView的跑马灯效果,即轮播
- Android开发 TextView实现跑马灯效果
- Android开发:TextView实现跑马灯效果
- Android开发实现TextView跑马灯效果
- Android开发实现TextView跑马灯效果
- android中TextView跑马灯效果
- Android中TextView跑马灯效果
- Android应用中TextView跑马灯效果
- android中TextView实现跑马灯效果
- Android中TextView实现跑马灯效果
- android中TextView中文本滚动的跑马灯效果
- 实现Android中TextView的跑马灯效果
- Android中TextView控件的跑马灯效果实现
- Android中TextView实现的“跑马灯”效果
- Android中继承TextView实现文字的跑马灯效果
- android TextView显示跑马灯的效果
- <<Effective C++>>读书笔记5: 实现
- iOS --统一导航栏“返回”键,并当push隐藏控制器底部tabBar
- 【HYSBZ1588: [HNOI2002]】营业额统计——伸展树
- Windows驱动开发(8) - 派遣函数
- POJ 2104K-th Number 划分树
- Android开发中如何让你的TextView有跑马灯效果?
- js 插件的写法
- 互联网秒杀业务架构设计 / 秒杀系统架构分析与实战
- LoadRunner下设置监控Windows系统资源
- Swift开发入门:按钮(UIButton)空间
- Android环境搭建
- 飛飛(四十三)复数类中的运算符重载(用友元函数编写)
- TP-LINK WR740N V5.7刷OpenWrt的一些经验
- 这是我的第一篇博客