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

 

Related Posts

Fix Plugin [id: ‘com.android.application’, version: ‘7.1.3’, apply: false] was not found in any of the following sources

Here is how to fix Plugin [id: ‘com.android.application’, version: ‘7.1.3’, apply: false] was not found in any of the following sources This error is caused by mismatching…

Get Age from Date of Birth in Java Android

Here is how to get a user’s age from date of birth If you need get a user’s age from a given date of birth string, this…

How to Check if String Array Contains a Specific String in Android

Here is how to get a specific value or String from Array in Android To check if a string array contains a specific string, you can use…

Make Android WebView Support Razorpay Payment

How to Support Razorpay Payment and UPI in Android WebView? Android webview is inexpensive and easy way to make apps for websites. But to support some specific…

Make Android Webview Support PayTM Google Pay PhonePe UPI

GooglePay, Phonpe and PayTM support in Android WebView If you have built an android app for your new ecommerce website or any other website that needs accept…

Leave a Reply

Your email address will not be published.