android:ellipsize - Make a Scrolling Marquee, using scrollHorizontally, in a TextView

How to Make a Scrolling Marquee, using scrollHorizontally, in a TextView

android:ellipsize was added in API Level 1
Related Method: setEllipsize - Make a Scrolling Marquee, using scrollHorizontally, in a TextView

1. Add a TextView.

2. Limit the number of lines and enable horizontal scrolling by adding scrollHorizontally to your TextView. 

    <TextView

        ...
        android:scrollHorizontally = "true"
    />


3. In the main.xml file, add the below line

  <TextView

    ....
       android:text="This is a really, really, really long line of text so you can see it scroll.This is a really, really, really long line of text so you can see it scroll."
      android:ellipsize = "marquee"
  />

4. If no other widgets are on the screen, this TextView will have focus by default, and will scroll automatically. However, if there are more widgets on the screen, when another widget gets focus, the scrolling will stop on the TextView because it has lost focus. To keep the focus on the TextView there are four options:

        a. add  
android:state_selected - Set Focus to a TextView, using state_selected, in XML

        b. add  requestFocus - Set Focus to a TextView, using requestFocus, in XML

        c. add setSelected(true) - Set Focus to a TextView, using Java

      d. add requestFocus - Set Focus to a TextView, using requestFocus, in Java

5. Compile and run!

Related Articles:
Resources:
http://developer.android.com/reference/android/widget/TextView.html#attr_android:ellipsize
http://developer.android.com/reference/android/R.attr.html#ellipsize