I am basically trying the achieve this design principle (from Google's Material Design):
Thus I've made a parent
RecyclerView
with a LinearLayoutManager
, then in the RecyclerView
adapter, I've put the child RecyclerView
with a GridLayoutManager
for the "rich media" section (Action area 2). Everything works fine, except for the fact that I've set the internal RecyclerView
grid to have a match_parent
width and a wrap_content
height, but it won't calculate the size of the content properly, seemingly leaving it at 0 & thus hidden. If I set the child RecyclerView
to a specific height, the items show within, but are then of course cut off at the bottom.
Others seem to have come across this problem, but in their case, both have linear layouts. (Also see "Khay's" answer here.)
Now my question is, how would one override the onMeasure
method as "pptang" did in the accepted answer of the linked question above, but within a custom GridLayoutManager
instead of a custom LinearLayoutManager
? I haven't posted my code here, because it's essentially the identical to the one linked, only that I need to make a custom GridLayoutManager
instead for the child RecyclerView
, so that it measures correctly as "pptang's" answer states.
Otherwise, is there a better way than to use 1 RecyclerView inside a 2nd RecyclerView? Can only 1 RecyclerView populate an activity/fragment both with a list of the above CardViews
and a grid of unique items within each CardView
?