Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android:how to move marquee text from right to left and left and right by clicking one button

how to move marquee text from right to left and left and right by clicking one button, how can i do this can any one help me?

like image 356
sravanreddy Avatar asked Dec 09 '22 22:12

sravanreddy


1 Answers

Try this;

Animation animationToLeft = new TranslateAnimation(400, -400, 0, 0);
animationToLeft.setDuration(12000); 
animationToLeft.setRepeatMode(Animation.RESTART);
animationToLeft.setRepeatCount(Animation.INFINITE);

Animation animationToRight = new TranslateAnimation(-400,400, 0, 0);
animationToRight.setDuration(12000); 
animationToRight.setRepeatMode(Animation.RESTART);
animationToRight.setRepeatCount(Animation.INFINITE);

TextView textViewMarqToLeft = (TextView) findViewById(R.id.textViewMarqToLeft);
TextView textViewMarqToRight = (TextView) findViewById(R.id.textViewMarqToRight);

textViewMarqToLeft.setAnimation(animationToLeft);
textViewMarqToRight.setAnimation(animationToRight);
String textLeft = "Left marquue"
String textRight = "Right marquue"
textViewMarqToLeft.setText(textLeft);
textViewMarqToRight.setText(textRight);
like image 72
mavixce Avatar answered May 17 '23 13:05

mavixce