Reputation: 101
I am trying to make a scrollable TextView where the user can scroll the updates.
I tried this:
XML:
<TextView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:textAppearance="?android:attr/textAppearanceSmall"
android:text=""
android:scrollbars="vertical"
android:id="@+id/updateText"
android:background="#ce000000"
android:textColor="#FFF"
android:padding="12dp"
android:textSize="13sp" />
and the code:
text.setMovementMethod(new ScrollingMovementMethod());
text.setText(updates.get(position).getUpdateText());
Yet it doesn't work properly.
It is laggy. Sometimes it works, but most of the time it doesn't.
Can anyone help?
Upvotes: 0
Views: 1711
Reputation: 1313
I recommend you to use a ScrollView and then put inside this TextView.
<ScrollView
android:layout_width="match_parent"
android:layout_height="match_parent"
xmlns:android="http://schemas.android.com/apk/res/android">
<TextView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:textAppearance="?android:attr/textAppearanceSmall"
android:text=""
android:scrollbars="vertical"
android:id="@+id/updateText"
android:background="#ce000000"
android:textColor="#FFF"
android:padding="12dp"
android:textSize="13sp" />
Upvotes: 0
Reputation: 7070
Set the below attributes to your TextView
android:maxLines = "20" // any number
android:scrollbars = "vertical"
Also setMovementMethod() -
text.setMovementMethod(new ScrollingMovementMethod());
Upvotes: 2