Thommy
Thommy

Reputation: 5407

Android "scroll" Text in TextView

I got the following situation: I have a String with about 40 - 50 Words and a TextView with max. 3 Lines. Is it possible to get the TextView to Display the a text snippet starting from a specific Word (not the first one) or Regex from the String? Example:

String: Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna

Shown in TextView: ...consetetur sadipscing elitr, sed diam nonumy...

Upvotes: 1

Views: 4361

Answers (2)

Lalit Poptani
Lalit Poptani

Reputation: 67286

You don't need to use a ScrollView actually. Just set the android:maxLines and android:scrollbars = "vertical" properties of textview in layout xml file. Then use the TexView.setMovementMethod(new ScrollingMovementMethod()) in the Code. Bingo!!!! It scrolls. Taken from this Answer.

Upvotes: 3

Arun
Arun

Reputation: 1668

you can implement the following change to your code:

urBtn.setEllipsize(TruncateAt.MARQUEE);
urBtn.setMarqueeRepeatLimit(-1);

This will set the text in the button to scroll always when focussed

Upvotes: 1

Related Questions