开发者

Simple Android Scrolling Text Ticker

开发者 https://www.devze.com 2023-04-12 04:40 出处:网络
I want to create a scrolling text ticker for a simple android app. I have a large list of quotes stored in an array, and I would like to randomly populate my ticker with the quotes: one quote scroll

I want to create a scrolling text ticker for a simple android app.

I have a large list of quotes stored in an array, and I would like to randomly populate my ticker with the quotes: one quote scrolls all the way through, then another is randomly chosen and scrolls its way through, and so on.

The ticker should chug al开发者_开发技巧ong regardless of what's been focused on or hovered over...

1) How do I create a text ticker for these purposes?

2) How do I populate the ticker with a steady stream of random quotes selected from my array?

Thanks


If I'm understand what you're trying to do properly you want to look at the ellipsize and marqueeRepeatLimit properties of TextView.

Via the API:

http://developer.android.com/reference/android/widget/TextView.html#attr_android:ellipsize

http://developer.android.com/reference/android/widget/TextView.html#attr_android:marqueeRepeatLimit

Also, look at this question for an implementation. From what I remember when I had to implement something like this is that the XML properties can be tricky. They interfere with one another and prevent the text from scrolling across the screen so it may take some toying with to get it right.

From there, populating it with different quotes is as simple as calling setText() on the TextView with the random quote that I assume you'll have stored in an array or database at the proper time.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号