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

sravanreddy picture sravanreddy · Jul 16, 2012 · Viewed 11.8k times · Source

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?

Answer

mavixce picture mavixce · Sep 4, 2012

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);