I want to create a scrolling counter that rises at a rate I give it for an Android app, I feel like there is no Android widget that does this well in the SDK and I wanted some idea how this should be accomplished, or even better an open source project around this idea.

4 Answers
4

This might not be a perfect answer, but at least a starting point. Discounting the animation and general fanciness, you can get most of the way there just by decorating a TextView with some fancy XML. I'll share what I did a few years ago to make a similar-looking screen area for a tip calculator:

Here's the XML. Each single digit is one TextView so you can change them individually. I'm showing two here but obviously there were 5 for the screenshot below.

This is amazing. On top of seeing if I can animate changes to the text view it might be perfect for my needs.
–
Seth HikariAug 16 '11 at 20:39

Glad to hear it. In my implementation the user could press on either the top or bottom portion of each TextView to change the number up or down, so I didn't need animations. If you do need them, I'm not sure if TextView will still be the way to go.
–
RaggedtoadAug 16 '11 at 20:42

I am animating a counter rising at a rate that the user would effect, but this is a really good start. The animation is need because it looks so much cleaner then just a refresh of numbers.
–
Seth HikariAug 16 '11 at 20:47

In Addition to raggedToad's answer: You can use the ViewAnimator class to add animations to your counter. Its easy to use. You can extend it, add all the digit textviews in onCreate(). Implement a method increment that handles the increment operation. Just call showNext to flip to the next view.

Thanks for adding that. Now I might go try that out on my old-school counter! :)
–
RaggedtoadSep 13 '11 at 17:38

So could I make an strip of numbers in an image, only show a portion of the image on screen, and animate the portion show moving then repeat the image when it reaches the end?
–
Seth HikariSep 15 '11 at 20:03

I'm pretty sure that this particular counter in your screenshot has some short animations (about 5 or 10 frames) for each transition from one number to the next. Maybe there are also some more for showing rapid transitions without actually stopping at the particular number with more blurring.

So the main task would be creating the graphics. Then it's just a matter of displaying the right frame at the right time.