Convert Figma logo to code with AI

Azoft logoCarouselLayoutManager

Android Carousel LayoutManager for RecyclerView

2,557
367
2,557
26

Top Related Projects

10,798

Project vlayout is a powerfull LayoutManager extension for RecyclerView, it provides a group of layouts for RecyclerView. Make it able to handle a complicate situation when grid, list and other layouts in the same recyclerview.

8,512

Epoxy is an Android library for building complex screens in a RecyclerView

ViewPager cards inspired by Duolingo

A scrollable list of items that centers the current element and provides easy-to-use APIs for cool item animations.

Cute view animation collection.

An Android Animation library which easily add itemanimator to RecyclerView items.

Quick Overview

CarouselLayoutManager is an Android library that provides a custom RecyclerView LayoutManager for creating carousel-like layouts. It allows for smooth scrolling and circular arrangement of items, making it ideal for creating image galleries, product showcases, or any other horizontally scrollable content with a focus on the center item.

Pros

  • Easy integration with existing RecyclerView implementations
  • Customizable item scaling and alpha effects for a visually appealing carousel effect
  • Supports both infinite scrolling and bounded layouts
  • Smooth scrolling and fling behavior

Cons

  • Limited documentation and examples
  • Not actively maintained (last update was several years ago)
  • May require additional customization for complex layouts
  • Potential performance issues with large datasets

Code Examples

  1. Basic setup of CarouselLayoutManager with RecyclerView:
val recyclerView: RecyclerView = findViewById(R.id.recycler_view)
val carouselLayoutManager = CarouselLayoutManager(CarouselLayoutManager.HORIZONTAL)
recyclerView.layoutManager = carouselLayoutManager
  1. Customizing item transformation:
carouselLayoutManager.setPostLayoutListener(object : CarouselZoomPostLayoutListener() {
    override fun transformChild(child: View, itemPosition: Int, fraction: Float) {
        child.scaleX = 1f - 0.2f * abs(fraction)
        child.scaleY = 1f - 0.2f * abs(fraction)
        child.alpha = 1f - 0.5f * abs(fraction)
    }
})
  1. Implementing infinite scrolling:
carouselLayoutManager.setCircleLayout(true)

Getting Started

To use CarouselLayoutManager in your Android project:

  1. Add the JitPack repository to your root build.gradle file:
allprojects {
    repositories {
        ...
        maven { url 'https://jitpack.io' }
    }
}
  1. Add the dependency to your app's build.gradle file:
dependencies {
    implementation 'com.github.Azoft:CarouselLayoutManager:1.2.1'
}
  1. Implement CarouselLayoutManager in your RecyclerView:
val recyclerView: RecyclerView = findViewById(R.id.recycler_view)
val carouselLayoutManager = CarouselLayoutManager(CarouselLayoutManager.HORIZONTAL)
recyclerView.layoutManager = carouselLayoutManager
recyclerView.adapter = YourCustomAdapter()

Competitor Comparisons

10,798

Project vlayout is a powerfull LayoutManager extension for RecyclerView, it provides a group of layouts for RecyclerView. Make it able to handle a complicate situation when grid, list and other layouts in the same recyclerview.

Pros of vlayout

  • More comprehensive layout system with multiple layout types (Grid, List, Sticky, etc.)
  • Better performance for complex layouts with large datasets
  • Actively maintained with regular updates and a larger community

Cons of vlayout

  • Steeper learning curve due to more complex API
  • Primarily documented in Chinese, which may be challenging for non-Chinese speakers
  • Larger library size, potentially increasing app size

Code Comparison

CarouselLayoutManager:

val layoutManager = CarouselLayoutManager(CarouselLayoutManager.HORIZONTAL)
recyclerView.layoutManager = layoutManager

vlayout:

val layoutManager = VirtualLayoutManager(context)
val viewPool = RecyclerView.RecycledViewPool()
recyclerView.layoutManager = layoutManager
recyclerView.setRecycledViewPool(viewPool)

Summary

CarouselLayoutManager is a simpler, more focused library for creating carousel-like layouts in Android. It's easier to implement but has limited functionality. vlayout, on the other hand, offers a more comprehensive layout system with better performance for complex layouts. However, it comes with a steeper learning curve and potential language barriers in documentation. The choice between the two depends on the specific project requirements and the developer's familiarity with complex layout systems.

8,512

Epoxy is an Android library for building complex screens in a RecyclerView

Pros of Epoxy

  • More comprehensive solution for building complex RecyclerView layouts
  • Supports data binding and view binding out of the box
  • Offers automatic diffing and efficient updates for better performance

Cons of Epoxy

  • Steeper learning curve due to its more complex architecture
  • Requires more boilerplate code for simple use cases
  • May be overkill for projects with simpler RecyclerView needs

Code Comparison

CarouselLayoutManager:

val layoutManager = CarouselLayoutManager(CarouselLayoutManager.HORIZONTAL)
recyclerView.layoutManager = layoutManager

Epoxy:

class MyEpoxyController : EpoxyController() {
  override fun buildModels() {
    // Build your models here
  }
}
val controller = MyEpoxyController()
recyclerView.setController(controller)

Key Differences

  • CarouselLayoutManager focuses specifically on creating carousel-like layouts
  • Epoxy provides a more general-purpose solution for complex RecyclerView layouts
  • CarouselLayoutManager is simpler to set up for basic carousel needs
  • Epoxy offers more advanced features like data binding and automatic diffing

Use Case Recommendations

  • Choose CarouselLayoutManager for simple carousel implementations
  • Opt for Epoxy when building complex, data-driven RecyclerView layouts with diverse item types

ViewPager cards inspired by Duolingo

Pros of ViewPagerCards

  • Utilizes ViewPager2, providing smoother scrolling and better performance
  • Implements a card-based UI, offering a visually appealing and modern design
  • Easier to integrate with existing Android projects due to its simplicity

Cons of ViewPagerCards

  • Less customizable compared to CarouselLayoutManager
  • Limited to horizontal scrolling only
  • Lacks advanced features like circular scrolling or custom item transformations

Code Comparison

ViewPagerCards:

class CardAdapter(private val items: List<CardItem>) : 
    RecyclerView.Adapter<CardAdapter.CardViewHolder>() {
    // Adapter implementation
}

viewPager.adapter = CardAdapter(cardItems)
viewPager.setPageTransformer(CardTransformer())

CarouselLayoutManager:

val carouselLayoutManager = CarouselLayoutManager(CarouselLayoutManager.HORIZONTAL)
recyclerView.layoutManager = carouselLayoutManager
recyclerView.adapter = CarouselAdapter(items)

ViewPagerCards offers a simpler implementation using ViewPager2, while CarouselLayoutManager provides more flexibility with RecyclerView. The latter allows for both vertical and horizontal scrolling, as well as more advanced customization options. However, ViewPagerCards may be easier to set up for basic card-based layouts and benefits from ViewPager2's improved performance.

A scrollable list of items that centers the current element and provides easy-to-use APIs for cool item animations.

Pros of DiscreteScrollView

  • More customizable with various scroll state callbacks and item transformation options
  • Supports both horizontal and vertical orientations out of the box
  • Actively maintained with recent updates and bug fixes

Cons of DiscreteScrollView

  • Slightly more complex API, which may require a steeper learning curve
  • Limited to discrete scrolling, which may not be suitable for all use cases
  • Lacks some advanced features like infinite scrolling

Code Comparison

DiscreteScrollView:

val discreteScrollView = DiscreteScrollView(context)
discreteScrollView.setOrientation(DSVOrientation.HORIZONTAL)
discreteScrollView.setAdapter(adapter)
discreteScrollView.setItemTransformer(ScaleTransformer.Builder().build())
discreteScrollView.addOnItemChangedListener { viewHolder, adapterPosition -> 
    // Handle item change
}

CarouselLayoutManager:

val carouselLayoutManager = CarouselLayoutManager(CarouselLayoutManager.HORIZONTAL)
recyclerView.layoutManager = carouselLayoutManager
recyclerView.adapter = adapter
carouselLayoutManager.setPostLayoutListener(object : CarouselZoomPostLayoutListener() {
    override fun transformChild(child: View, itemPosition: Int, fraction: Float) {
        // Custom transformation logic
    }
})

Both libraries offer similar functionality for creating carousel-like layouts in Android applications. DiscreteScrollView provides more built-in features and customization options, while CarouselLayoutManager offers a simpler API with more flexibility for custom transformations. The choice between the two depends on specific project requirements and developer preferences.

Cute view animation collection.

Pros of AndroidViewAnimations

  • Offers a wide variety of pre-built animations for Android views
  • Easy to implement with a simple, chainable API
  • Supports custom animations and easing functions

Cons of AndroidViewAnimations

  • Focused solely on view animations, not layout management
  • May require additional code for complex UI structures
  • Limited to individual view animations, not suited for carousel-like layouts

Code Comparison

AndroidViewAnimations:

YoYo.with(Techniques.FadeIn)
    .duration(700)
    .playOn(findViewById(R.id.textView));

CarouselLayoutManager:

RecyclerView recyclerView = findViewById(R.id.recycler_view);
CarouselLayoutManager layoutManager = new CarouselLayoutManager(CarouselLayoutManager.HORIZONTAL);
recyclerView.setLayoutManager(layoutManager);

Summary

AndroidViewAnimations is a library focused on providing easy-to-use animations for individual Android views, offering a wide range of pre-built animations and a simple API. It's great for adding visual flair to UI elements but lacks layout management capabilities.

CarouselLayoutManager, on the other hand, is specifically designed for creating carousel-like layouts in RecyclerViews. It provides a custom LayoutManager for achieving circular or infinite scrolling effects, which is not a feature of AndroidViewAnimations.

While both libraries enhance the visual appeal of Android apps, they serve different purposes. AndroidViewAnimations is ideal for quick, individual view animations, while CarouselLayoutManager is better suited for creating complex, scrollable layouts with a carousel effect.

An Android Animation library which easily add itemanimator to RecyclerView items.

Pros of recyclerview-animators

  • Offers a wide variety of pre-built animations for RecyclerView items
  • Supports custom animations for add, remove, and change operations
  • Easy to implement with minimal code changes

Cons of recyclerview-animators

  • Focuses solely on item animations, not layout management
  • May require additional configuration for complex animation scenarios
  • Limited control over item positioning compared to CarouselLayoutManager

Code Comparison

recyclerview-animators:

val animator = SlideInLeftAnimator()
recyclerView.itemAnimator = animator

CarouselLayoutManager:

val layoutManager = CarouselLayoutManager(CarouselLayoutManager.HORIZONTAL)
recyclerView.layoutManager = layoutManager

Key Differences

  • recyclerview-animators is primarily for animating RecyclerView items, while CarouselLayoutManager focuses on creating a carousel-like layout
  • CarouselLayoutManager provides more control over item positioning and rotation
  • recyclerview-animators is more versatile for general RecyclerView animations across different layouts

Use Cases

  • Use recyclerview-animators for adding engaging animations to list items in various layouts
  • Choose CarouselLayoutManager when specifically implementing a carousel or circular layout for RecyclerView

Community and Maintenance

  • recyclerview-animators: More popular, with higher stars and forks on GitHub
  • CarouselLayoutManager: Less actively maintained, but still functional for its specific use case

Convert Figma logo designs to code with AI

Visual Copilot

Introducing Visual Copilot: A new AI model to turn Figma designs to high quality code using your components.

Try Visual Copilot

README

Android LayoutManager for RecyclerView to support Carousel view style

Examples

Example

Example

Integration with Gradle

    implementation 'com.mig35:carousellayoutmanager:version'

Please replace version with the latest version:

Description

This LayoutManager works only with fixedSized items in adapter. To use this LayoutManager add gradle (maven) dependence and use this code (you can use CarouselLayoutManager.HORIZONTAL as well):

final CarouselLayoutManager layoutManager = new CarouselLayoutManager(CarouselLayoutManager.VERTICAL);

final RecyclerView recyclerView = (RecyclerView) findViewById(R.id.recycler_view);
recyclerView.setLayoutManager(layoutManager);
recyclerView.setHasFixedSize(true);

To enable items center scrolling add this CenterScrollListener:

recyclerView.addOnScrollListener(new CenterScrollListener());

To enable zoom effects that is enabled in gif add this line:

layoutManager.setPostLayoutListener(new CarouselZoomPostLayoutListener());

Full code from this sample:

// vertical and cycle layout
final CarouselLayoutManager layoutManager = new CarouselLayoutManager(CarouselLayoutManager.VERTICAL, true);
layoutManager.setPostLayoutListener(new CarouselZoomPostLayoutListener());

final RecyclerView recyclerView = (RecyclerView) findViewById(R.id.recycler_view);
recyclerView.setLayoutManager(layoutManager);
recyclerView.setHasFixedSize(true);
recyclerView.setAdapter(new TestAdapter(this));
recyclerView.addOnScrollListener(new CenterScrollListener());

Customizations

You can enable and disable circular loop using two arguments constructor. Pass true to enable loop and false to disable.

You can make carousel Vertically and Horizontally by changing first argument.

You can change zoom level of bottom cards by changing scaleMultiplier argument in CarouselZoomPostLayoutListener. Big thanks to JeneaVranceanu!

Contact

Feel free to get in touch.

Email:      mig35@mig35.com
Website:    http://www.azoft.com
Twitter:    @azoft
LinkedIn:   https://www.linkedin.com/company/azoft
Facebook:   https://www.facebook.com/azoft.company

License

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

   http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.