Why implement this effect?

It started with a click effect in the company’s project, where the text would scroll in unbroken sequence.

I found several libraries of running lantern on Github, and I thought all of them could be realized. However, every time I clicked the animation of Fluttering heart, the scrolling text would start to roll again, which is not the desired effect of the product. (After returning home, I wrote a demo to test several good libraries on Github. All of them were ok. It was really embarrassing.)

Let’s start with three GitHub libraries that are very good at implementing a running lantern

  • Sunfusheng /MarqueeView this is an extension of the ViewFlipper implementation. The results are as follows:

  • Gongwen/MarqueeViewLibrary it is expanded the ViewFlipper control implementation, the effect of the implementation is as follows:

  • 385841539/MarqueeView this is an inherited View to implement, the author said that the implementation of the library is a TextView, especially when the page also exists EditText, the effect is as follows:

Worship above a few gods, the following began to paste I achieve the effect, not ugly, ha ha ha.

  • dongxi346/MarqueeLibEffect achieved:

A brief introduction to my implementation ideas

It’s also done with a custom View, and I only have two ways to scroll, left to right, right to left.

  • Scroll from left to right (the X-axis is gradually decreasing and increasing). The key is the length of the scroll. I’m using **ViewThe length of the +Length of textMake the scroll length, and when it exceeds this length, draw from scratchView**
  • If you scroll from right to left (the x axis is decreasing), the scroll length is also **ViewThe length of the +Length of textDo the length of the scroll, when exceeding this length, fromViewOn the right side of theA thirdBegan to drawView**

Clear these two ideas can be, specific can view the source code, welcome to add friends to learn from each other, wechat: weixin1105894953