On button click I want to change list view to gridview as on shopping-cart pages but my layout looks like link shown below.
//For displaying the row as linear list view
case R.id.ivGrid:
ivList.setVisibility(View.VISIBLE);
ivGrid.setVisibility(View.GONE);
LinearLayoutManager llm = new LinearLayoutManager(context);
rcvProducts.setLayoutManager(llm);
break;
//For displaying the row as gridview
case R.id.ivList:
ivList.setVisibility(View.GONE);
ivGrid.setVisibility(View.VISIBLE);
GridLayoutManager glm = new GridLayoutManager(this,2,GridLayoutManager.VERTICAL, false);
rcvProducts.setLayoutManager(glm);
break;
Just use a GridLayoutManager and change the span count from 1 to 2 and back again.