How to Make a TextView Scrollable in Android Java

To make a TextView scrollable in android java, Add these lines in your project

 

In XML :

android:maxLines="1000"
android:scrollbars = "vertical"

 

In Java Activity :

YourTextview.setMovementMethod(new ScrollingMovementMethod());

 

Explanation

android:maxLines="1000"
android:scrollbars = "vertical"

Here, android:maxLines=”1000″ sets the number of lines that can be scrolled, i set it to 1000, you can change this value to your need

android:scrollbars = “vertical”  sets the direction to which you can scroll, example: horizontal




 

Full XML Example

 

<TextView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:maxLines="1000"
        android:scrollbars = "vertical"
        android:id="@+id/textview"
        android:text="Result..."
        android:layout_centerHorizontal="true"
        />

 

I guess java example is not needed. if you need it, just comment below

 

, ,

Post navigation

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.