Android: Why Not use an Image Carousel if you have lots of images to show!
--
Do you know that creating an image carousel in Android is easier then you think! š
Recently in a project, I have to show some images for preview. I am thinking to use an image carousel library to show the images. But the library I found does not make me feel good š! They are old or have discontinued/old library dependency š!
So I thought letās try to make one š! Then I checkout the existing libraries source codes and I found that creating a carousel is a two-line code š²!
Really!
To create a carousel (ViewPager like view) just attach a RecyclerView
to a SnapHelper
!
Thatās it! Try it yourselfā¦
Though you have to create a RecyclerView adapter, design item layout, which consists of ImageView, the ImageView should be fully match_parent in height and width, styling the view, adding indicator, adding navigator, listenerā¦ā¦ā¦ š
For the lazy š“ā¦
That means to make everything work you have to write more codes. So to save you from that I create an image carousel library, Why Not! Image Carousel!
Itās simple to use and fully customizable.
How to useā¦
Add repository to the root build.gradle
file:
Add dependencies to the module build.gradle
file:
Replace X.X.X
with the latest version of the library. Check out the latest release version from here.
Finally add the ImageCarousel
to your XML layout:
Then add item to the carousel:
Thatās all need to create the first carousel view in the following image:
Feeling interesting š¤? Then check out the details usage from the repository. A Sample project also included here, using both Kotlin and Java š.
Repository š https://github.com/ImaginativeShohag/Why-Not-Image-Carousel
Sample š https://github.com/ImaginativeShohag/Why-Not-Image-Carousel/tree/master/sample
Like it? thenā¦
Use it⦠clone it⦠fork it⦠give PRs and finally, give a star to the repository and share it if you likeā¦