get RecyclerView Span Size - Android User Interface

Android examples for User Interface:RecyclerView

Description

get RecyclerView Span Size

Demo Code


import android.support.v7.widget.GridLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.util.Log;
import java.util.ArrayList;

public class Main{
    private static Integer getSpanSize(RecyclerView rv) {
        final RecyclerView.LayoutManager lm = rv.getLayoutManager();
        if (lm != null && lm instanceof GridLayoutManager)
            return ((GridLayoutManager) lm).getSpanCount();
        return 1;
    }/*from   w  w w . ja v  a 2  s.  c  o  m*/
}

Related Tutorials