实现的效果图如下
ellipsize 可以设置跑马灯效果 具体代码设置如下
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:ellipsize="marquee"
android:layout_marginTop="100dp"
android:focusableInTouchMode="true"
android:singleLine="true"
android:marqueeRepeatLimit="marquee_forever"
android:text="君不见,黄河之水天上来,奔流到海不复回。君不见,高堂明镜悲白发,朝如青丝暮成雪。人生得意须尽欢,莫使金樽空对月。天生我材必有用,千金散尽还复来。烹羊宰牛且为乐,会须一饮三百杯。岑夫子,丹丘生,将进酒,杯莫停"
android:textColor="@android:color/holo_red_dark">
<requestFocus />
</TextView>
android:ellipsize="marquee" //设置为跑马灯效果
android:marqueeRepeatLimit="marquee_forever" //设置为重复走动
android:focusable="true" //获取焦点
android:singleLine="true" //单行文字
android:focusableInTouchMode="true" //获取focus