1

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...
Lucifer
  • 29,392
  • 25
  • 90
  • 143
Thommy
  • 5,070
  • 2
  • 28
  • 51
  • you can use TextView method: `setMaxLines` to make the last has `...`, if the line is bigger than max lines, but you want the first, may be need your custom implements. – idiottiger Jan 09 '12 at 08:53
  • Why not manipulate the string before setting it into the textview? – reTs Jun 26 '12 at 09:31

2 Answers2

3

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.

Community
  • 1
  • 1
Lalit Poptani
  • 67,150
  • 23
  • 161
  • 242
1

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

Arun
  • 1,658
  • 1
  • 14
  • 21
  • Sorry that is not what I want. I don't want the text to be scrollable, i just want it to scroll at a specific position and then stay there. – Thommy Jan 09 '12 at 08:55