Android Scrollable TextView | Vertical Using XML and Programmatically

Making TextView scrollable on Android you need to use a android:scrollbars properties of your TextView in your layout’s XML file.

Then use the below code in the Activity file. This method will enable scrolling on TextView.



ScrollView is needed when you want to show too long text and should fit into one screen.

Complete code of Android Scrollable TextView

Let’s build an app and demonstrates it, Here is the complete step by step tutorial:-

Step 1. Create an android project in the android studio (Follow this tutorial: Android First Program in Android Studio).

Step 2. Open the strings.xml file.

Android Long in scroll Using XML

Step 3. Add your long text in the strings.xml file.

You can add your own text, this is only for testing purpose.

Step 4. Add the below code in activity_main.xml

Setting the height of TextView 300dp to see how it works.

Step 5. Add the below code in MainActivity.kt

For java, you can use it from the tutorial top section.

Step 4. Now Run the application, in an emulator or on your Android device.

Output screenshot Android Scrollable TextView:-

Android Scrollable TextView

Download Link and Source of Scrollable TextView Android kotlin code in Github

Do comment if you have any doubts or suggestions on this tutorial.

Note: This example (Project) is developed in Android Studio 3.3.2. Tested on Android 9 ( Android-P), compile SDK version API 28: Android 9.0 (Pie)
TargetSdkVersion=28″Coding in Kotlin

2 thoughts on “Android Scrollable TextView | Vertical Using XML and Programmatically

Leave a Reply

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