views:

433

answers:

4

I am trying to center itemRenderers in a horizontal list if the number of items in the list is less than the maximum visible number. Has anyone found a good way to do this?

See an illustration of what I mean if it is hard to picture.

Thanks!

A: 

One solution that comes to mind would be to add invisible renderers to achieve the same centering.

Brandon
That might work, although I'd have to add / remove null items to get the placement correct as you scrolled through the results and that sounds easy to break. I'm wondering if I need to write something custom to take care of this case.
John Williams
A: 

You might want to consider using a horizontal box or "Hbox" instead of a horizontal list component. This will allow you to use the horizontal align property to set center. If not, simply extend the horizontal list component to accept a center align property, and copy it from the hbox to your new extended component.

Mike
A: 

Would paddingRight or paddingLeft accomplish what you're looking for? If you combine it with setting the columnWidth and the columnCount, that would allow you to adjust where the items first appear.

Christopher W. Allen-Poole
+1  A: 

Override the measure() method - I've writen a blog entry here: http://flexmonkey.blogspot.com/2010/05/centre-aligned-horizontallist-in-flex.html

simon

Simon Gladman
That does look like it will do the trick! We've changed the layout since this question was asked, but the next time I need to do this I'll tackle it using your solution. Thanks!
John Williams