[Android] TextView实现走马灯效果
来源:互联网 发布:mysql.tar.gz 编辑:程序博客网 时间:2024/04/29 08:01
在TextViw中,如果文本的长度超出了显示范围,可以使文本水平滚动显示,类似于走马灯的效果,只需在XML布局文件中,为TextView设置如下几个属性即可。
android:ellipsize="marquee"。
android:marqueeRepeatLimit="XX"。其中XX表示循环次数,为大于0的整数或marquee_forever(无限循环)。
android:focusable="true"。只有处于焦点状态的TextView才能显示走马灯效果。
如下是完整的XML代码。
- <?xml version="1.0" encoding="utf-8"?>
- <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
- android:orientation="vertical"
- android:layout_width="fill_parent"
- android:layout_height="fill_parent">
- <TextView android:id="@+id/textview3"
- android:layout_width="fill_parent"
- android:layout_height="wrap_content"
- android:text="start这里是一个使TextView实现走马灯效果的例子end"
- android:singleLine="true"
- android:ellipsize="marquee"
- android:marqueeRepeatLimit="marquee_forever"
- android:focusable="true"
- android:background="#FFF"
- android:textColor="#000"
- android:textSize="20dp"
- android:layout_margin="10dp"
- android:padding="10dp"/>
- </LinearLayout>
实现效果如下图。
0 0
- [Android] TextView实现走马灯效果
- [Android] TextView实现走马灯效果
- [Android] TextView实现走马灯效果
- TextView实现走马灯效果
- android TextView 走马灯效果
- Android TextView走马灯效果
- Android TextView 走马灯效果
- Android TextView走马灯效果
- Android TextView的走马灯效果
- Android实现TextView走马灯效果同时自动更新显示当前时间
- android 实现textView的走马灯
- 多个TextView同时实现走马灯效果
- 多个TextView实现走马灯效果
- Android中一直走马灯效果的TextView
- android中设置TextView/Button 走马灯效果
- android Textview 使用之二:走马灯效果
- Android中一直走马灯效果的TextView
- android中TextView的文字实现动态效果,走马灯效果,闪烁效果
- [Android] AutoCompleteTextView:自动完成输入内容的控件(自动补全)
- 关于 OOP、C和C++
- cookie的相关知识
- 5个Xcode开发调试技巧(转自CocoaChina)
- hdu 2896
- [Android] TextView实现走马灯效果
- hdu 3065
- Android开发获取唯一设备ID
- [Android] TextView的垂直滚动效果
- dinic模板 邻接矩阵
- 黑马程序员-----匿名内部类(黑马视频)
- 字符设备与块设备的区别
- HttpClient 实现跳转请求
- 庭审管理中动态显示今天起7日内的数据,动态查询,并根据已有数据判断新增和修改时的时间冲突问题