Sunday, November 2, 2014

Android : Using RecyclerView with StaggeredGridLayoutManager not showing anything



I'm trying out RecyclerViews to build out something like Pinterest staggered layout. However, while LinearLayoutMnager and GridLayoutManager both work well in the same code, replacing that with StaggeredGridLayoutManager doesn't show any items. Putting breakpoints in the code shows that it gets the item count and items, but rendered nothing. Any idea on what I am missing?



final RecyclerView rView = (RecyclerView) findViewById(R.id.app_list);
rView.setClickable(true);
rView.setHasFixedSize(true);
rView.setLayoutManager(new StaggeredGridLayoutManager(5, StaggeredGridLayoutManager.HORIZONTAL));
rView.setAdapter(new ItemListAdapter(this, getItems()));


Replacing the StaggeredGridLayoutManager with just the GridLayoutManger everything works.



rView.setLayoutManager(new GridLayoutManager(this, 5));

No comments:

Post a Comment