androidlayoutwrappanelgrid-layout

Android - WrapPanel equivalent


I've read some of WPF/Silverlight controls, and I really liked some of them. One of the panels that I wish Android could have is WrapPanel (as a layout, of course). Has anyone else come across some code that implement it?

The way it layout its children is: for each row (or column, depending on the orientation), if there is enough space for the child, put it, otherwise, go to the next row (or column, depending on the orientation).

I think that the new GridLayout can give the same functionality, but sadly it isn't available for most APIs yet, and I can't find a way of how to compile only its code in order to have its code within my app.

I would also be interested in some useful layouts implementation that you've seen.


Solution

  • there is a new component on the sdk manager that is called "android support" which allows us to use gridlayout by getting to ".../extras/android/support/v7/gridlayout" . the required API is 7 , but it's ok since it matches the majority of the devices . it's not the same as wrapPanel , but it's very similar.

    sadly, they didn't add a working sample . i've succeeded using it at runtime , but not by using xml .

    if anyone could present a working project which uses xml (together with the library) , it would be very nice .


    EDIT: You can also choose to use the RecyclerView.