例:
<TextView
android:layout_width="100px"
android:layout_height="wrap_content"
android:text="@string/hello"
android:singleLine="true"
android:ellipsize="marquee"
android:marqueeRepeatLimit="marquee_forever"
android:focusable="true"
android:focusableInTouchMode="true"
/>
解释一下:
android:ellipsize="marquee"
textview中样式是跑马灯效果。
android:marqueeRepeatLimit="marquee_forever"
循环次数,这里是无限循环,可以根据需要写具体的次数,例如5。
android:singleLine="true"
textview中字体单行显示,否则会这行,不会出现跑马灯效果。
android:focusable="true"
android:focusableInTouchMode="true"
使textview获取焦点,这样字体就会自动滚动。