Android跑马灯效果

本文为
痛点就是起点
原创文章,可以随意转载,但需注明出处。
用 Android 实现跑马灯效果,前提是显示的内容较长,超过屏幕的宽度,不然实现跑马灯没有意义。
- 一个 TextView
android:singleLine="true"
android:ellipsize="marquee"
android:focusable="true"
android:focusableInTouchMode="true"
- 多个 TextView
用继承 TextView 类来实现,isFocused 方法返回 true。
- 效果