4

My TextView scrolls only when the finger is in contact with the screen and only for the distance which the finger moved. How to enable fling scrolling in the TextView?

 <TextView
    android:id="@+id/helloWorld"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_centerHorizontal="true"
    android:layout_centerVertical="true"
    android:text="@string/hello_world"
    tools:context=".HelloWorld" 
    android:scrollbars="horizontal|vertical"
    android:scrollbarSize="@dimen/scrollBarSize"
    android:scrollbarFadeDuration="2000"/>

I found some sample code here: Vertical fling scrolling of text line in Android Please tell me there is a better way to do this!

Community
  • 1
  • 1
radiantRazor
  • 467
  • 3
  • 13

1 Answers1

-6

Here you don't want to use a ScrollView .

Just use the following lines in xml file

android:maxLines = "AN_INTEGER"

android:scrollbars = "vertical"

properties of your TextView in your layout's xml file.

Then use:

yourTextView.setMovementMethod(new ScrollingMovementMethod())

in your java code.

Hybrid Developer
  • 2,239
  • 28
  • 49
  • 2
    This doesn't enable fling scrolling (just "regular" scrolling as far as the finger is moved) and is also almost an exact copy of the response http://stackoverflow.com/a/3256305/1016939 ... – lxgr Jul 23 '15 at 14:02