How to reverse the direction of marquee of a TextView

前端 未结 8 944
孤城傲影
孤城傲影 2020-11-30 05:16

I want to reverse the direction of marquee in the TextView. By default, the text moves from Right to Left, I want it to move from Left to Right. How can I do this?

8条回答
  •  悲&欢浪女
    2020-11-30 05:35

    I would suggest you create your own component with this behavior.

    Like this: ViewFlipper with a single TextView as it's child (with your text displayed).

    flipper.setInAnimation(AnimationUtils.loadAnimation(this, R.anim.marquee_in));
    flipper.setOutAnimation(AnimationUtils.loadAnimation(this, R.anim.marquee_out));
    

    Marquee in:

    
    
        
    
    

    Marquee out:

    
    
        
    
    

    You have to tweak a bit the duration to make it look like a "native" animation. :-)

提交回复
热议问题