gitmyhub

AndroidStaggeredGrid

Java ★ 4.7k updated 3y ago ▣ archived

An Android staggered grid view which supports multiple columns with rows of varying sizes.

A deprecated Android library from Etsy that displays a Pinterest-style grid where items can have different heights, with support for variable column counts and scroll-position sync on device rotation.

JavaAndroidGradlesetup: moderatecomplexity 2/5

AndroidStaggeredGrid is an Android library from Etsy that displays a grid of items where each item can have a different height, similar to the layout style popularized by Pinterest. Unlike a standard Android grid where every cell is the same size, a staggered grid arranges items in columns while letting each row vary in height based on its content.

The library was built because the Etsy Android app needed a stable grid implementation with specific features that no existing Android library provided at the time. The main requirements were: configurable column counts for portrait and landscape orientations, the ability to sync the scroll position when the user rotates the phone, and support for header and footer views above and below the grid.

To use it, you add the StaggeredGridView component to your layout XML, set options like the number of columns and the spacing between items, and attach a standard Android list adapter. The grid handles the layout from there. The README notes that all item views should maintain their own width-to-height ratio as column widths change on rotation, and includes a sample image view class that does this automatically.

The README prominently notes that this library was deprecated in September 2015 and is no longer maintained. The authors recommend using Google's own RecyclerView with its StaggeredGridLayoutManager instead, which provides the same layout style with ongoing support. The Etsy team moved to that solution internally as well.

For anyone who still needs to reference the code, it is available under the Apache 2.0 license. It targets Android 2.3.3 and above and uses Gradle for building.

Where it fits