How to animate the textview (very very long text )scroll automatically horizontally

前端 未结 11 936
长发绾君心
长发绾君心 2020-12-16 06:30

I am not interested in Marquee because, in Marquee you can not control the speed of marquee. I have tried to animate the textview but Parent view clips the text at the end e

11条回答
  •  半阙折子戏
    2020-12-16 07:11

    This is what worked for me. Place your textview inside a scroll view and then perform TranslateAnimation on the scrollview's child, my case its the LinearLayout. I am actually adding multiple views dynamically inside this linear layout.

    
        
        
    
    
    TranslateAnimation slide = new TranslateAnimation(0, 0, height, -textLayout.getHeight());
        slide.setDuration(movementSpeed);
        slide.setRepeatCount(-1);
        slide.setRepeatMode(Animation.RESTART);
        slide.setInterpolator(new LinearInterpolator());
    
    textLayout.startAnimation(slide);
    
    height --> The point start scrolling up (in my case device height (device bottom))
    movementSpeed --> scrolling speed
    

提交回复
热议问题