5

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 .

can anyone please help? also , if you guys can give some more useful layouts implementation that you've seen , please write them too .

android developer
  • 114,585
  • 152
  • 739
  • 1,270

2 Answers2

0

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.

android developer
  • 114,585
  • 152
  • 739
  • 1,270
0

You can find a pretty good implementation here: Line-breaking widget layout for Android

It does not have all the options of the WPF WrapPanel but it's a good start.

Community
  • 1
  • 1
Max
  • 1,810
  • 3
  • 26
  • 37