How to Make a Scrolling Marquee, using scrollHorizontally, in a TextView
android:ellipsize was added in API Level 1Related 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 lineandroid:scrollHorizontally = "true"
/>
<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
d. add requestFocus - Set Focus to a TextView, using requestFocus, in Java
5. Compile and run!
Related Articles:
- Deprecated: Make a Scrolling Marquee, using singleLine, in a TextView
- android:ellipsize - Add an ellipsis in a TextView
- Stop a Rolling Marquee on a TextView
- Deprecated: android:singleLine Set EditText to One Horizontally Scrolling Line
- android:maxLines - Set the Maximum Viewable Lines of text in a TextView
- android:lines - Change the number of lines of text viewable in a TextView/EditText
http://developer.android.com/reference/android/widget/TextView.html#attr_android:ellipsize
http://developer.android.com/reference/android/R.attr.html#ellipsize