This app is an example. how to create collages with RecyclerView. See an example, how it's working:


1) If you have not added Jitpack to your repositories, add it:

allprojects {
    repositories {
        maven { url '' }

2) Then add to your app (or another module, where you will use the lib) this dependency:

implementation 'com.github.GrishinSergey:CollageImageView:v2.0.0'

3) In your layout you should place this:

    android:layout_height="wrap_content" />

And in your source you should place next code.

One of major changes between v1 and v2 is that now it is necessary to provide previewer. This is the way, how this lib supports different libraries for previewing images. Look to app module to see details

collageViewId.itemPreviewLoader = GlideItemPreviewLoaderImpl.Builder(context).build()

Now it is possible to set radius for images in collage. Just paste value in dp in collage to make it rounded

val radius = TypedValue.applyDimension(
    4F, // the radius value

Here is an example, how to fill list of urls to images. Let's say you have list of images from your API, so you can convert them to CollageItemUrlData

val images = { singlePhoto ->
    CollageItemUrlData(singlePhoto.url).apply {
        this.width = singlePhoto.width
        this.height = singlePhoto.height

Last, which is necessary, call setup method. It takes now three params:

  • list of CollageItemUrlData,
  • radius
  • listener of clicks
collageViewId.setup(images, radius) { position ->
    Toast.makeText(context, "clicked position is $position", Toast.LENGTH_SHORT).show()