How To Scroll Android TextView

Hi there! Today we’re going to do a script that will make a scrolling Android TextView. I found this one useful when I’m testing my other code snippets. The situation is, my text output exceeds the height of my android device screen, I cannot see the whole output unless I make the TextView scrolling.

Let’s rock and scroll! :))
Let’s rock and scroll! :))

We will have the following code on our main activity –

package com.example.ScrollingTextView;

import android.os.Bundle;
import android.widget.TextView;

public class ScrollingTextView extends Activity {
    TextView tv;
    //Called when the activity is first created. 
    public void onCreate(Bundle savedInstanceState) {
        //textViewWithScroll is the name of our TextView on main.xml = (TextView) this.findViewById(;
        //initializing a blank textview
        //so that we can just append a text later
        //display the text 10 times
        //so that it will exceed the device screen height
        //and be able to scroll
        for(int x = 1; x < 11; x++ ){
            tv.append("Hi there!n");
            tv.append("Did you know that...n");
            tv.append("I'm handsome? Hahaha! Just kidding.n");

And then the following codes on our layout file – main.xml

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android=""

    android:layout_below="@+id/DownloadData" >  
        android:text="Text here..."

We will have something like this on the output:droidscroll

Thanks for reading this How To Scroll Android TextView!


6 responses to “How To Scroll Android TextView”

  1. i need help on horizontal scrolling.
    i have created a webview which contains text and i want to swipe the page exactly one at a time

  2. excuse me, i use your xml code but this message show up, “the id “DownloadData” is not defined everywhere”, it happen in this code bellow “android:layout_below=”@+id/DownloadData”

    what should i do ??

Leave a Reply

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