Item in RecyclerView not filling it's width match_parent
The problem is within the new support library 23.2.0
, so I reverted that to 23.1.1
and it works fine. If I find a solution, or what to change, I will let you know, otherwise I'm leaving this thread open, if someone else finds a better answer.
UPDATE
Ok, so I decided it was time to fix this, as we need to move to new support libraries and I finally found an answer.
The problem was/is that the new LayoutManager
is using autoMeasure()
and somehow it changed all my match_parent
to wrap_content
, so here is what you need to do, if you encounter a similar problem.
First create LinearLayoutManager llm = new LinearLayoutManager(getActivity());
then llm.setAutoMeasureEnabled(false);
and finally you set the LinearLayoutManager
to your RecyclerView
, but do this AFTER recyclerView.setAdapter(yourAdapter);
Here is a quick example:
recyclerView.setAdapter(adapter);
recyclerView.setHasFixedSize(true);
LinearLayoutManager llm = new LinearLayoutManager(getActivity());
llm.setAutoMeasureEnabled(false);
recyclerView.setLayoutManager(llm);
To walkaround this bug I changed:
recyclerView.setLayoutManager(new LinearLayoutManager(getActivity());
with:
recyclerView.setLayoutManager(new GridLayoutManager(getActivity(), 1));