Implementing RecyclerView has become pretty simple and straight forward as it evolved. I will try to keep it simple and short so that it becomes easy at both our ends. I have created a simple news app which shows news with the headline and a short description. I will be using this app to show how it's done. Below are the steps to implement a RecyclerView in Kotlin.

Add dependencies in .gradle file Add Recyclerview in .xml layout Make a custom adapter for recyclerview Add the adapter to Recyclerview in Activity

And you are done with a smooth scrolling RecyclerView.

1. Add dependencies in .gradle file

Add the required dependencies needed for RecyclerView and Kotlin and make sure to use the latest versions. The perks of using latest versions are really good.

2. Add Recyclerview in the .xml layout

Add the RecyclerView component in your mainActivity.kt and make sure width and height are adjusted accordingly so that it fits the screen with all its child elements and sufficient space for the user to scroll.

3. Make a custom adapter for recyclerview.

Make a custom adapter which extends RecyclerView.Adapter<ViewHolder>. A recyclerView adapter has many fuc which you can override. There are mandatory ones and optional ones. A basic adapter looks the one which I have shown above. Below the list_item I have used in the above adapter.

4. Add the adapter to recyclerview in Activity

At the end add the adapter to the recyclerView with Layoutmanager like shown above.

And you are all set to run the app and see the magic. This is pretty straight forward, but the complexity comes when you are trying to make a recyclerView which handles a lot of animations and gestures. But the recyclerView component is so flexible and customizable which will make developers life easier.

You can find the whole project here in Github. This is a public repo which has many demo projects so you can use GitZip to download a specific project from this repo. Paste this link in GitZip and you have it.