2010/10/24

Making a real marquee out of Android TextView

Android TextView supports a Marquee ellipsis method, which starts animating the text in the TextView if it's width exceeded the width of the view.
But let's say you want it to animate the text constantly? Here's a classic trick - pad the string until it goes out of the width of the view, so it will start the scrolling.


The hard part here was to find out how to calculate the line width (since the TextView itself doesn't supply that info. Had to dig android sources for that.