explaingit

yarolegovich/discretescrollview

5,782JavaAudience · developerComplexity · 2/5Setup · easy

TLDR

An Android library that creates a scrollable list where one item is always centered and neighboring items peek in from the edges, like a horizontal card carousel or media picker.

Mindmap

mindmap
  root((DiscreteScrollView))
    What it does
      Centered item carousel
      Peek neighboring cards
      Animated transitions
    Configuration
      Horizontal or vertical
      Scale transformer
      Infinite scroll wrap
    Events
      Item change callback
      Scroll progress listener
      Animation end callback
    Setup
      Gradle dependency
      XML layout view
      Attach adapter
Click or tap to explore — scroll the page freely

Code map

Detail Auto

An interactive map of this repo's files and how they connect — its source is parsed live in your browser. Click Visualize to build it.

filefunction / class

Things people build with this

USE CASE 1

Add a card carousel to an Android screen where the selected card is centered and adjacent cards are partially visible.

USE CASE 2

Build a horizontal media picker with animated scale transitions between items.

USE CASE 3

Create a vertical infinite-scroll selector, like a slot machine or a date picker wheel.

USE CASE 4

Attach scroll event listeners to sync other UI elements with which card is currently selected.

Tech stack

JavaAndroidRecyclerView

Getting it running

Difficulty · easy Time to first run · 5min

Add one Gradle dependency, set an adapter, and add the view to your XML layout, no LayoutManager configuration needed.

In plain English

DiscreteScrollView is an Android library that creates a scrollable list where one item is always centered on screen, and the items to its left or right remain partially visible at the edges. The effect is similar to a horizontal card picker or a media carousel. Think of it like Android's built-in ViewPager, but with more flexibility in how much of the neighboring items shows through. The library is built on top of Android's RecyclerView component, which means setup follows the same pattern developers already know: attach an adapter that supplies your item views, and the library handles the rest. You do not set a LayoutManager because the library provides its own internally. Adding it to a layout takes a few lines of XML, and a working picker requires only setting an adapter in code. Several behaviors can be configured beyond the basics. Items can be animated during transitions using a transformer, which gives each card a custom visual effect as it moves in or out of the center position. A built-in scale transformer makes it easy to shrink non-selected cards without writing any animation code. Orientation can be set to horizontal or vertical. A slide-on-fling option lets users skip past multiple items in one swipe gesture. Infinite scroll wraps the list end-to-end using an adapter wrapper class. Scroll can be locked in specific directions if the UI needs it. The library provides callback interfaces for listening to scroll events, letting you track when a scroll starts and ends, how far through a transition the list is at any given moment, and when the selected item changes. This is an open source Java project. A sample app on Google Play demonstrates the different configuration options. The project accepts contributions and includes guidance in the README on how to report issues effectively.

Copy-paste prompts

Prompt 1
Using DiscreteScrollView, add a horizontal card carousel to my Android activity where each card shows a product image and title, with the selected card scaled up.
Prompt 2
How do I implement infinite scrolling in DiscreteScrollView so the list wraps around from the last item back to the first?
Prompt 3
Set up a DiscreteScrollView with a custom scale transformer that shrinks non-selected cards to 80 percent of their normal size.
Prompt 4
Show me how to listen for when the centered item changes in DiscreteScrollView and update a page indicator dot below the carousel.
Open on GitHub → Explain another repo

← yarolegovich on gitmyhub — every repo by this author, as a profile.

Verify against the repo before relying on details.