1、 Textview跑马灯效果:
实现起来比较简单,只需对Textview控件添加如下属性:
android:ellipsize="marquee"
android:focusable="true"
android:focusableInTouchMode="true"
android:marqueeRepeatLimit="marquee_forever"
android:scrollHorizontally="true"
android:ellipsize:
设置当文字过长时,该控件该如何显示。有如下值设置:”start”—–省略号显示在开头;”end”——省略号显示在结尾;”middle”—-省略号显示在中间;”marquee” ——以跑马灯的方式显示(动画横向移动)
android:marqueeRepeatLimit:
在ellipsize指定marquee的情况下,设置重复滚动的次数,当设置为marquee_forever时表示无限次
android:scrollHorizontally:设置文本超出TextView的宽度的情况下,是否出现横拉条。
android:focusableInTouchMode:触摸获取焦点
源码:
<TextView android:layout_width="fill_parent" android:layout_height="wrap_content" android:layout_marginTop="20dp" android:ellipsize="marquee" android:focusable="true" android:focusableInTouchMode="true" android:marqueeRepeatLimit="marquee_forever" android:scrollHorizontally="true" android:text="在那个古老的不再回来的夏日, 无论我如何地去追索 " android:textColor="#ff0000" android:textSize="20dp" > </TextView>
转载于:https://www.cnblogs.com/ouyangxiaoqing/archive/2013/01/22/2871311.html
相关资源:textview(跑马灯效果)文字长短不限循环播放