Using layout_columnWeight & layout_rowWeight in RecyclerView
I have a Fragment with a root element of a 2×3 GridLayout, which contains several RecyclerView(s).
The RecyclerView(s) at [1,0], [0,1] & [1,2] have either a dynamic (but not changing) width or height, and I want the RecyclerView at [1,1] to fill the remaining space.
I attempted to do this using a combination of layout_width="0dp", layout_width="wrap_content", layout_height="0dp", layout_height="wrap_content", layout_columnWeight="1" & layout_rowWeight="1"
.
However, when I call SetLayoutManager & SetAdapter in OnResume it does not call OnCreateViewHolder or OnBindViewHolder, I am guessing because they have widths/heights of 0 at that point.
I have confirmed that the Adapters do have data and that ItemCount do return the correct values. I have tried calling the Notify methods, with no success.
My issue is:
What can I do to force the GridLayout
& RecyclerView
(s) to update the layout in OnResume
(or wherever is appropriate) when initially creating my Fragment
(without manually calculating the elements)?