How to reverse the direction of marquee of a TextView

前端 未结 8 942
孤城傲影
孤城傲影 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:45

    The functionality you are looking for does not appear to be available at this time.

    You could create your own reverse marquee textview from the source in TextView.java but there are quite a few references to "marquee" within it. I counted more than 50 so it may take some time to reverse the scroll direction.

    I thought some bi-directional language support might allow you to trick the textview into scrolling left to right but Android does not seem to support RTL languages very well.

    For now your only option would be to accept the direction of the marquee or create your own TextView class that supports your functionality.

    I would look at this section from line 3810 - 3815

      if (mMarquee != null && mMarquee.isRunning()) {
            canvas.translate(-mMarquee.mScroll, 0.0f);
        }
    

    removing the minus sign before mMarquee becomes:

      if (mMarquee != null && mMarquee.isRunning()) {
            canvas.translate(mMarquee.mScroll, 0.0f);
        }
    

    obvously you will need to make additional changes but this would point you in the right direction (literally).

提交回复
热议问题