Alex Facciorusso Alex Facciorusso - 10 months ago 139
Android Question

Put an indeterminate progressbar as footer in a RecyclerView grid

How to get indeterminate circular indicator for "Scroll up to load more" in a grid RecycleView?

The pattern is described there: in "Two-phased loads" and "Example 2: Scroll up to load more" example videos.

I'm trying to accomplish this using the new RecyclerView, but I can't find a "not-too-hackish" way to do that, firstly because there is not a way to add a footer that cover a full row in the grid. Any suggestions?

Answer Source

It is very simple to do that.

The solution is to use the same approach of the LinearLayoutManager with a GridLayoutManager and then use the method setSpanSizeLookup on the LayoutManager like this:

mLayoutManager.setSpanSizeLookup(new GridLayoutManager.SpanSizeLookup() {
        public int getSpanSize(int position) {
                case MyAdapter.VIEW_TYPES.Product:
                    return 1;
                case MyAdapter.VIEW_TYPES.Progress:
                    return 2; //number of columns of the grid
                    return -1;

This will automatically make the item cover a full row of the grid (if the row is not totally empty this item goes to the next row).