I'm wondering how we can style the whole row containing more than 1 item in a GridLayout (so the columnCount
is set to 2 or above).
Trying to style all the items in the same row to fake styling the whole row is not what I want. Although doing like that works in some cases but not for all cases.
Here is a screenshot helping you understand more about what I want:
There are 2 rows as in the image above, the effect here is just a simple continuous shadowed and white background (without any space between the 2 items or at least visually looked like that), but that's just for demonstrative purpose. The actual effect may be various and more complicated and that's when styling each item may not solve the problem easily.
I've tried Googling around but there is nothing helpful found.
In fact the number of items is not fixed, there is a list of items, and I would like to show them in a RecyclerView
with layout manager set to GridLayoutManager
. Technically we can just style each item using some template XML. Based on that, I can only think of the idea to group each 2 items in a larger item (called a row). Treat each row as one item, so we can style the row as the whole. However doing so may complicate the underlying data (because now the items are not flat, they are grouped by 2 adjacent items), also to have those grouped items we need to perform one more step (grouping) on the input items. If the number of items is small enough, doing something like that is acceptable, however if they are very large (as usually the case in reality) I don't think we should follow that approach.