Posts

Showing posts with the label recyclerview

Databinding in RecyclerView - Android - Kotlin

Image
Hey Guyss!! Already we have seen the basics of Databinding and how to use it in previous  post . Now let's see how to use Databinding in RecyclerView . And Its gonna be a short post. ;) You can find the Project in GitHub . Prerequisite: build.gradle First, we have enable dataBinding in app-level build.gradle                           android {                                     dataBinding {                                             enabled = true                                     }                            } Next, we hav...

RecyclerView with different number of columns using SpanSizeLookup

Image
We already know how to design RecyclerView. But how to create RecyclerView with different columns depending on its row? Like below image? Yeah, we can do that, by using two different layouts with different viewType on Adapter. Another way is do some logic to do so. But, it's cumbersome. Luckily, we have another simple way to do that using SpanSizeLookUp . Let's see how to implement that in this post. Implementation: build.gradle Include the following in app-level gradle file. implementation 'com.android.support:recyclerview-v7:27.0.2' implementation 'com.android.support.constraint:constraint-layout:1.1.0-beta5' recycler.xml <?xml version= "1.0" encoding= "utf-8" ?> <android.support.constraint.ConstraintLayout xmlns:android= "http://schemas.android.com/apk/res/android" android:layout_width= "match_parent" android:layout_height= "match_parent" xmlns:ap...

Shimmer Layout like Facebook in Android - Kotlin

Image
While loading data from API, we used to show boring loaders. But in Facebook's app, one loading screen will be displayed. That one looks interesting know. We can also do that shimmer effect in our Andorid App using Shimmer library by Facebook. Let's start. Implementation: build.gradle Include the following in app-level gradle file. implementation 'com.facebook.shimmer:shimmer:0.1.0' colors.xml Include the following color in values -> colors.xml <color name= "placeholder_color" > #dddddd </color> Design: 1. First we have to design placeholder layout that is similar to your RecyclerView's adapter layout. placeholder.xml <?xml version="1.0" encoding="utf-8"?> <android.support.constraint.ConstraintLayout xmlns:android= "http://schemas.android.com/apk/res/android" xmlns:app= "http://schemas.android.com/apk/res-auto" android:layout_width...

RecyclerView with Kotlin in Android

Image
Hi,                                  This is my first post in Blog. So lets begin with something new, fun and easy ;) Lets do RecyclerView with Kotlin. 1. Create New Project : First, create a new project in Android Studio with Kotlin support. 2. Design Layouts :  Design layout with RecyclerView  as below: activity_main.xml <?xml version="1.0" encoding="utf-8"?> <android.support.constraint.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"     xmlns:tools="http://schemas.android.com/tools"     android:layout_width="match_parent"     android:layout_height="match_parent"     xmlns:app="http://schemas.android.com/apk/res-auto">     <android.support.v7.widget.RecyclerView         android:id="@+id/recyclerView"       ...