To make text in TextView scroll, you must meet the following factors:
1,textview text width over textview width
2,android:ellipsize= "Marquee"
3, scrolling only occurs when TextView gets the focus. So add Android:focusableintouchmode= "true" android:focusable= "true"
The easiest thing to ignore is the third one.
Scrolling repeat number setting:
android:marqueerepeatlimit= "Marquee_forever"
Look at a TextView property android:ellipsize to realize the effect of the happy lantern
In the Android system, the TextView realizes the effect of the horse lamp, and must have the following conditions:
1, android:ellipsize= "marquee"
2, TextView must be a single display, that content must exceed TextView size
3, TextView to get the focus to scroll
XML code:
Android:ellipsize= "marquee", android:singleline= "true"
Java code:
Mtvtext.settext ("Singing and spreading the Wind festival, Lei Feng Spirit http://www.111cn.net/, very long very long very long very long data");
Mtvtext.setsingleline (TRUE);
Mtvtext.setellipsize (Truncateat.marquee);
PS:TextView.setHorizontallyScrolling (TRUE); Allow text to slide horizontally
TextView can also set the number of scrolling times for the marquee effect, as follows:
XML Code settings:
android:marqueerepeatlimit= "1". 1 represents 1 times,-1 represents an infinite loop.
Java Code settings:
Mtvtext.setmarqueerepeatlimit (-1);