如果对显示没有特别要求可以直接使用属性就能做到,在布局文件中将TextView属性设置一下:
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:ellipsize="marquee"
android:focusable="true"
android:focusableInTouchMode="true"
android:marqueeRepeatLimit="marquee_forever"
android:scrollHorizontally="true"
android:singleLine="true"
android:text="哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈"
android:textSize="17sp" />
//设置为跑马灯显示
android:ellipsize="marquee"
//获取焦点