In ApiDemo of Android, there is a Button drive effect, but it is still a little different if it is changed to TextView.
Define Marquee, mainly in Project/res/layout/main. xml
[Html]
<SPAN style = "COLOR: #993300"> <TextView
Android: layout_width = "40px"
Android: layout_height = "wrap_content"
Android: text = "Test marquee for TextView"
Android: layout_gravity = "center"
Android: ellipsize = "marquee"
Android: singleLine = "true"
Android: focusable = "true"
Android: marqueeRepeatLimit = "marquee_forever"
Android: focusableInTouchMode = "true"
Android: scrollHorizontally = "true"
/> </SPAN>
<TextView
Android: layout_width = "40px"
Android: layout_height = "wrap_content"
Android: text = "Test marquee for TextView"
Android: layout_gravity = "center"
Android: ellipsize = "marquee"
Android: singleLine = "true"
Android: focusable = "true"
Android: marqueeRepeatLimit = "marquee_forever"
Android: focusableInTouchMode = "true"
Android: scrollHorizontally = "true"
/>
Key points:
(1) The length set by layout_width is shorter than the actual length of text, that is, layout_width does not show all text before it will have the effect of riding a horse.
(2) ellipsize indicates that marquee is used
(3) singleLine indicates single row display
(4) marqueeRepeatLimit indicates the number of drive lights displayed: marquee_forever-unlimited uninterrupted display
[Html]
<SPAN style = "COLOR: #993300"> <Button
Android: id = "@ + id/buttonMarquee"
Android: layout_width = "320px"
Android: layout_height = "wrap_content"
Android: text = "@ string/textMarquee"
Android: singleLine = "true"
Android: focusable = "true"
Android: selectAllOnFocus = "true"
Android: ellipsize = "marquee"
Android: marqueeRepeatLimit = "marquee_forever"
/> </SPAN>
<Button
Android: id = "@ + id/buttonMarquee"
Android: layout_width = "320px"
Android: layout_height = "wrap_content"
Android: text = "@ string/textMarquee"
Android: singleLine = "true"
Android: focusable = "true"
Android: selectAllOnFocus = "true"
Android: ellipsize = "marquee"
Android: marqueeRepeatLimit = "marquee_forever"
/>