0

From the prevois post, Is there a way to make ellipsize=“marquee” always scroll? I have create a vertical maquee textview. But my question is how can I hold the animation around 5 sec when it moving to a point and than resume and finish the animation.

For example:

mAnimation2 = new TranslateAnimation(0f, 0f, 20f, -20f);
mAnimation2.setDuration(5000);
mAnimation2.setStartOffset(5000); 
mAnimation2.setRepeatMode(Animation.RESTART);
TextView tv = (TextView)findViewById(R.id.text); tv.setAnimation(mAnimation2);

I have define the above animation and set it to TextView. How can I stop the animation 5 sec when the textview was at coordinate (0,0) and than continues the animation?

Community
  • 1
  • 1
WynixToo
  • 161
  • 4
  • 15

1 Answers1

2

You could take this MarqueeView implementation and customize it up to your desire: http://b.ivity.asia/2010/12/01/extended-marquee-in-android/

Sebastian Roth
  • 11,344
  • 14
  • 61
  • 110
  • Great!!! ur code is work!!! thanks u save my time. but may I ask some question? the MarqueeView is it need to focus then it only will restart the animation? i.e: the animation only will run again when I touch the screen. Do you have and idea to solve it? mean it will keep running itself. Thanks and sorry about my bad english.. – WynixToo Dec 29 '10 at 04:01
  • Sure, you can do that easily. Probably by adding a onClickListener, and call the startAnimation block there. Be sure to remove the automatic startAnimation within the MarqueeView. – Sebastian Roth Dec 29 '10 at 04:13
  • Do you mean call the startAnimation block from onClickListener? I think my question is no clear. let me explain again. I need the animation auto run forever. but now in my app it didn't run the "mMoveText1TextIn" after "mMoveText1TextOut" finish. when I just simple touch the screen again, then "mMoveText1TextIn" only will start porperly. How can make the "mMoveText1TextIn" run again without touch the screen? should I override the onFocusChanged? Thanks and sorry about my bad english. – WynixToo Dec 29 '10 at 09:50
  • You might try that. But sounds a little complicated. Do you have the entire source code somewhere? – Sebastian Roth Dec 29 '10 at 10:24
  • I'm just using your source code. But I just have do some edit. I need the TextView moving from bottom to top. so I set "mMoveText1TextIn = new TranslateAnimation(0, 0, 0, -20)" and "mMoveText1TextOut = new TranslateAnimation(0, 0, 20, 0)". other I just follow your code. And I have notice if I comment the "mTextField1.setOnClickListener(l);", then the animation wont restart anymore.Thanks – WynixToo Dec 30 '10 at 01:31
  • Tried for hours to make it scroll vertically, gave up. – SteveCav Feb 25 '12 at 02:17
  • Maybe @WynixToo could share his solution. Else you could open a github repo and let us take a look? – Sebastian Roth Feb 27 '12 at 17:09