banner
🔥🔥🔥Banner 2.0 来了!Android广告图片轮播控件,内部基于ViewPager2实现,Indicator和UI都可以自定义。
A Java Android library that adds a smoothly looping image carousel to your app, with built-in transition effects, a customizable dot indicator, and automatic pause and resume tied to the activity lifecycle.
This is an Android library that adds an image carousel to a mobile app. A carousel, called a banner in the README, is a UI element that automatically slides through a set of images one after another, commonly used for featured content sections or advertisements at the top of an app screen.
Version 2.0 of the library is built on top of ViewPager2, the current Android Jetpack component for swiping between pages. This makes it compatible with the modern androidx package set. Developers add it to a project through Gradle with a single dependency line, and it works without any external image-loading library bundled in, giving teams the freedom to use whichever loading tool they prefer.
The library supports horizontal and vertical scrolling, automatic looping with a configurable delay (default three seconds), and swipe-to-turn-off if needed. Several built-in page transition effects are included, such as depth, zoom-out, rotate, scale, and alpha fades, and multiple effects can be layered together. There are also gallery and parallax-style display modes that show partial neighboring slides at the edges.
The dot-style page indicator that appears below the images is fully customizable: color, size, spacing, shape, and position can all be adjusted through XML attributes or code. The library provides a base class for building a completely custom indicator if the built-in options do not fit.
Setup involves extending a BannerAdapter class (similar to RecyclerView's adapter pattern), attaching the banner to an Activity or Fragment, and calling a lifecycle observer method so the carousel automatically pauses and resumes with the screen. The README is written in Chinese and includes annotated code samples for common use cases.
Where it fits
- Add an auto-scrolling image carousel to the top of an Android home screen or product page with a single Gradle dependency.
- Apply built-in transition effects like zoom-out, depth, rotate, or parallax to a slideshow of promotional images.
- Customize the dot page indicator's color, size, shape, and position to match your app's design through XML attributes.
- Show a gallery-style banner that reveals partial neighboring slides at the edges for a layered look.