转载自: https://blog.csdn.net/u013085291/article/details/46874019
其实没啥用的效果,只是习惯做做笔记了,仅此而已
注意跑马灯的长度必须大于控件的宽度
<TextView
android:layout_width="match_parent" <!-- 宽度-->
android:layout_height="wrap_content" <!-- 高度-->
android:ellipsize="marquee" <!-- 设置跑马灯显示效果-->
android:focusable="true" <!-- 获取焦点 要显示跑马灯效果,必须要获取焦点-->
android:singleLine="true" <!-- 设置单行显示(很重要,关系到能不能正常显示) 有许多人说不能显示就是没有设置这个-->
android:marqueeRepeatLimit="marquee_forever" <!-- 跑马灯次数,这里是一直循环显示-->
android:focusableInTouchMode="true" <!-- 在触摸模式下获得焦点-->
android:scrollHorizontally="true" <!-- 启用水平滚动条-->
android:text="这才是真正的文字跑马灯效果,但是并没有什么卵用" <!-- 文本内容-->
android:textSize="30sp" <!-- 字体大小-->
>
</TextView>
<!-- 实际实现 -->
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:ellipsize="marquee"
android:scrollHorizontally="true"
android:focusable="true"
android:singleLine="true"
android:focusableInTouchMode="true"
android:marqueeRepeatLimit="marquee_forever"
android:text="dwdwafawawgawgawgawgawhkuhukhukhukhkuhukhukhkuga"
android:textSize="50sp"
>
<requestFocus/>
</TextView>