Other than @SanatiSharif’s and @sohrab’s answer, you have to follow below mandatory step.
Make sure you call setLayoutManager
, something like below.
recyclerView.setLayoutManager(new LinearLayoutManager(getContext()));
before setting adapter into recyclerView, otherwise it is not going to work.
You can customize it if you need.
this link will give you some idea of how LayoutManager works.