gitmyhub

MarqueeView

Java ★ 3.8k updated 5y ago

俗名:可垂直跑、可水平跑的跑马灯;学名:可垂直翻、可水平翻的翻页公告

An Android library that displays scrolling text banners in any of four directions, like a news ticker or announcement strip, configured entirely from XML with no custom animation code needed.

JavaAndroidGradlesetup: easycomplexity 2/5

MarqueeView is an Android UI component written in Java that displays scrolling text, similar to a ticker strip or announcement banner. It supports four scroll directions: top-to-bottom, bottom-to-top, left-to-right, and right-to-left. Android developers add it to a project through a single Gradle dependency line.

Adding it to a screen layout uses standard Android XML. You configure the component with attributes for animation duration, the pause interval between items, text size, text color, alignment (left, center, or right), single-line mode, scroll direction, and font. Once those are set, the view handles the cycling animation on its own.

In Java code, you supply a list of strings and call startWithList to begin. For a single long message you call startWithText instead. The library also supports custom data objects: implement a small interface with one method that returns the display text, then pass a list of those objects directly. Custom entry and exit animations can replace the defaults if you want a different visual feel. A click listener lets you respond when a user taps a scrolling item, with access to the item position and text.

The README, written primarily in Chinese, includes a note about preventing ghost animations when the component appears inside a ListView or RecyclerView. You call stopFlipping when a view detaches and startFlipping when it reattaches, keeping the animation in sync with the screen lifecycle.

The README does not include a license section, contribution guidelines, or test instructions. The package repository linked in the header is Bintray, which shut down in 2021, so the published artifact may no longer be available at that address.

Where it fits