textView automatically move upwards
i have a scrollview ,it include one textView, the textView have many lines,in other word the textView entire screen size, if i want to see all strings in the textView,i need scroll the scrollbar,but i donot want to so,i want the textView or the screen automatic moving upwards 开发者_开发知识库interval for a period of time ,so that don't need user operations, how to realize it Looks like ebook effect?
If I understand correctly you want an auto scrolling TextView, like a marquee right?
You can use Labeeb approach but the problem there is that you don't know beforehand the size of the screen.
First, You will need to create a timer in the onCreate method of your activity to run in background. It should run in a separate thread not to block your UI.
Use schedule(TimerTask task, long delay, long period)
setting the delay and period to the same amount. (or not its up to you).
You can use the Scroller class to initiate and control a scrolling event. You can set the scroll distance, the scrolling starting position, the end position, and so on. Ideally, you should create an algorithm to calculate the "amount of scrolling" given a screnn size. You can, however, scroll a fixed number of lines that would be < than the number of lines a small 2'' screen has (I think those are roughly the smaller android device screens).
Finally, use the timer to fire the Scrolling Method (task) you just created.
Not so good but also works (kinda!) You can also use the built in android marquee property. It can simulate the desire effect.
android:marqueeRepeatLimit="int"
android:ellipsize="marquee"
But it scrolls horizontaly and runs continuously.
i don't know is this a good idea, Here you can use each line in a separate textview and you can use requestfocus of each textview in a definite interval of time
精彩评论