<TextView
android:id="@+id/tv_marquee"
android:layout_width="match_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:textColor="@android:color/holo_red_dark"
android:textSize="@dimen/textSize" />
注:
1、显示的文字要超过给定的长度。
2、activity中加上:
tv_marquee.setSelected(true);
参考:
https://blog.youkuaiyun.com/u010112268/article/details/79730852