ArhamTechMind

RecyclerView

Adding header view to recyclerview with gridlayout manager

Adding header view to recyclerview with gridlayout manager Android Adding header view to recyclerview with gridlayout manager: To add a header to a recyclerview with a gridlayout, first the adapter needs to be told that the header view is the first position – rather than the standard cell used for the content. Next, the layout manager …

Adding header view to recyclerview with gridlayout manager Read More »

Item OffsetDecoration for GridLayoutManager in RecycleView

Item OffsetDecoration Item OffsetDecoration for GridLayoutManager in RecycleView.Following example will help to give equal space to an item in GridLayout. Item OffsetDecoration for GridLayoutManager in RecycleView.Following example will help to give equal space to an item in GridLayout. ItemOffsetDecoration.java public class ItemOffsetDecoration extends RecyclerView.ItemDecoration { private int mItemOffset; private int spanCount = 2; public ItemOffsetDecoration(int …

Item OffsetDecoration for GridLayoutManager in RecycleView Read More »

Android RecyclerView Tutorial

Step 1:build.gradle compile ‘com.android.support:cardview-v7:26+’ compile ‘com.android.support:recyclerview-v7:26.+’ Step 2:main_activity.xml <?xml version=“1.0” encoding=“utf-8”?>   <RelativeLayout xmlns:android=“http://schemas.android.com/apk/res/android”     xmlns:app=“http://schemas.android.com/apk/res-auto”     xmlns:tools=“http://schemas.android.com/tools”     android:layout_width=“match_parent”     android:layout_height=“match_parent”     tools:context=“csdevbin.arham.recyclerviewdemo.MainActivity”>     <android.support.v7.widget.RecyclerView         android:id=“@+id/my_recycler_view”         android:layout_width=“match_parent”         android:layout_height=“match_parent”         android:scrollbars=“vertical” /> </RelativeLayout> Step 3: card.xml <LinearLayout xmlns:android=”http://schemas.android.com/apk/res/android”  xmlns:card_view=”http://schemas.android.com/apk/res-auto”     xmlns:tools=”http://schemas.android.com/tools”     android:layout_width=”match_parent”     android:layout_height=”wrap_content”>     <!– A CardView that contains a …

Android RecyclerView Tutorial Read More »