Epoxy: Airbnb's View Architecture on Android
Article Summary
Eli Hart from Airbnb reveals how they eliminated RecyclerView boilerplate while building complex screens with 8+ view types. Their solution handles diffing, animations, and state management automatically.
Airbnb open-sourced Epoxy, their Android view architecture library that simplifies building complex RecyclerView-based UIs. The library takes a React-inspired compositional approach where developers describe what to show, and Epoxy handles the rendering details including automatic diffing and animations.
Key Takeaways
- Models define layout, binding, and span—adapter handles display complexity automatically
- Built-in diffing algorithm updates only changed views, enabling smooth animations
- Annotation processor generates hashCode and setters from @EpoxyAttribute fields
- Stable IDs and view state saving work out of the box
- Powers Airbnb's listing details page for faster loads and smoother transitions
Epoxy reduces RecyclerView complexity by letting developers declare what to show while the library handles diffing, animations, and state management automatically.
About This Article
Airbnb's search results page needed to display eight different view types in a single scrollable RecyclerView. Headers, carousels, loaders, error messages, and disclaimers all had to coexist, which made the adapter code complex and required manual change tracking.
Eli Hart's team used Epoxy's annotation processor to automatically generate hashCode methods from @EpoxyAttribute fields. This enabled a diffing algorithm that could detect model changes without requiring manual notify calls.
The listing details page loaded faster and had smoother shared element transitions. RecyclerView virtualization meant only visible portions of the view hierarchy were rendered, which reduced layout passes and memory usage when the page first loaded.