I have 2 columns in my GridLayout
. What I want to do is make those columns take up half of the width of the screen each and then have its child contents fill their
When you use a GridLayoutManager
you are able to use setSpanSizeLookup
. Here is a snippet from my project which should help to use this method properly:
if (mAdapter == null) {
final int columnCount = getResources().getInteger(R.integer.numberGridColumns);
mLayoutManager = new GridLayoutManager(getActivity(), columnCount);
mLayoutManager.setSpanSizeLookup(new GridLayoutManager.SpanSizeLookup() {
@Override
public int getSpanSize(int position) {
switch (mAdapter.getItemViewType(position)) {
case ListAdapter.VIEW_TYPE_ONE_COLUMN:
return columnCount;
case RecipeListAdapter.VIEW_TYPE_FULL_COLUMN:
default:
return 1;
}
}
});
mRecyclerView.setLayoutManager(mLayoutManager);
mAdapter = new RecipeListAdapter(mPresenter);
mRecyclerView.setAdapter(mAdapter);
}
mAdapter.notifyDataSetChanged();