Is there an equivalent for iOS UICollectionView in Android SDK?
I need to implement similar "table" layout as below, but as there are many cells (user will scroll the screen to view all) I need cell re-using for performance reasons.
+-----------------+----------+--------+
| cell 1 | cell 2 | cell 3 |
+-----------------+--+-------+--+-----+
| cell 4 | cell 5 | cell 6 |
+---------+---+------+-----+----+---------+
| cell 7 | cell 8 | cell 9 |
+-------------+------------+--------------+
I was thinking to use separate GridView for each row, but I need to scroll all table at once and I am not sure if cell re-using will work properly that way.
What is the best way to implement the table above?
If you can set the cells to a predefined width, you should check out TwoWayGridView.
Otherwise, what you are looking for is in the AOSP's experimental branch and it's called StaggeredGridView. They have started the implementation but it's quite young and unprepared, though it may give you a hint as to where to start.
Generally, there are different approaches to this, and from my experience you may end up in having to write a good robust view recycler and re-user yourself, to be able to rely on existing API and widgets, where you will only have to calculate the width of the scroll and lay the views as they detach or need to be attached to your containers upon scrolling events.
I think the StaggeredGridView or QuiltView libraries will help you solve your issue. Using these libraries, we can arrange the images according to the width and height
If you are using quilt view, you can arrage it in different styles by changing the ScaleType
, etc.
I haven't tried the TwoWayGridView but is worth trying. I hope this helps.. :)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With