Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Table with variable column width per row (similar to UICollectionView for iOS)

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?

like image 273
Petr Peller Avatar asked Jan 28 '13 09:01

Petr Peller


2 Answers

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.

like image 155
Ben Max Rubinstein Avatar answered Nov 15 '22 12:11

Ben Max Rubinstein


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.. :)

like image 34
Aswathy P Krishnan Avatar answered Nov 15 '22 13:11

Aswathy P Krishnan