android:scrollbars - Add a Vertical Scrollbar to a TextView

How to Add a Vertical Scrollbar to a TextView

android:scrollbars was added in API Level 1

android:scrollbars: Defines which scrollbars should be displayed on scrolling or not.

1. Add the MovementMethod for a TextView.

2. In the main.xml file, add the below code to your TextView to add a vertical scrollbar.

<TextView
      ...
      android:scrollbars = "vertical"
 />

3. FYI: All the android:scrollbars options:

none - No scrollbar is displayed
horizontal - Displays horizontal scrollbar only. (horizontal doesn't seem to work for a TextView)
vertical - Displays vertical scrollbar only.
"horizontal|vertical" - Displays both horizontal and vertical scrollbars

4. Compile and run!

Related Articles:

Resources: