Implementation method of running lantern effect in textview in Android

Conditions:

1、android:ellipsize=”marquee”

2. The textview must be displayed in a single line, that is, the content must exceed the size of the textview

3. Textview needs focus to scroll

Mtvtext.settext ("data exceeding text length");

mTVText.setSingleLine(true); Set single line display

mTVText.setEllipsize(TruncateAt.MARQUEE); Set the display effect of the running light

TextView.setHorizontallyScrolling(true); // Lets text slide horizontally

Textview can also set the number of scrolls of the running lamp effect

android:marqueerepeatlimit="1"。 1 represents 1 time, - 1 represents infinite loop.

Java code settings:

mTVText.setMarqueeRepeatLimit(-1);

. XML file:

. java file

The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
分享
二维码
< <上一篇
下一篇>>