Marcus Riemer
Marcus Riemer

Reputation: 7688

Shouldn't I be using a RecyclerView?

I want to implement a schedule-like overview as List and as Grid View. Currently this works using a RecyclerView and swapping out the LayoutManager at Runtime. This works fine in general, but as soon as I tuned the grid cells to have a fixed height, I realised that the RecyclerView does not respect the wrap_content layout property and instead introduces whitespace between my grid items.

Grid Layout

I then stumbled over more or less the same question for the linear LayoutManager and the third-party provided specialisations of the LayoutManager. A quick searched revealed nothing similar for the GridLayoutManager and I am beginning to suspect I am going down the wrong road:

Apart from the easy switching between layouts, there seems to be no reason for me to work with a recycler view:

So I am currently evaluating to simply switch to separate Fragments using an ordinary ListView and GridView. But this does feel a little like working against the intentions of Android ... After all, they introduced a single view that (in theory) should exactly do what I need.

Am I missing something obvious that could turn out to be painful when using those "legacy" Views to get the job done? Or are there maybe other, more specific Views that allow switching from linear to grid layouts apart from the RecyclerView?

If this should be of importance: I am using Xamarin.Android, not native Java. But I would be willing to port some code from Java to C#.

Upvotes: 1

Views: 94

Answers (1)

yigit
yigit

Reputation: 38243

Follow this ticket:

https://code.google.com/p/android/issues/detail?id=74772

It is not merged yet but soon should be merged and WRAP_CONTENT support should be available in the next version (23.1.1+) or the one after.

Upvotes: 1

Related Questions