Skip to main content

Anchoring, Sizing, and Layouts

5 replies [Last post]
hoopajoob
Offline
Joined: 2010-02-03
Points: 0

I want to create a component that contains 3 vertical components: a Label on top, a List in the middle, and a Label on the bottom. I want the 2 Labels to always be anchored to the top and bottom. I want the List to always fill up the middle regardless of how many items are in the list without pushing the bottom Label off the screen.

What is the best way to accomplish this? I’ve tried some various Layout combinations and some sizing logic but have not come up with a working solution yet.

Thanks for any help!

Reply viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
myinstinct
Offline
Joined: 2008-10-24
Points: 0

if you use a BorderLayout and put the top label in the NORTH, the bottom label in the SOUTH and the list in the CENTER - does that work for you?

hoopajoob
Offline
Joined: 2010-02-03
Points: 0

That keeps the individual components in the right order but doesn't anchor the label on the bottom and fill out the center. I think maybe I'm missing the piece that makes my component size itself to a fixed size to fill up the maximum space available. The List is being resized when the number of items changes causing my component's size to change and the bottom label moves up and down.

Not sure if I should be trying to get the parent component or the List to size itself to the maximum and the best way to go about doing so. I'm new to LWUIT and still learning ...

Thanks again.

myinstinct
Offline
Joined: 2008-10-24
Points: 0

what type is the parent container?

hoopajoob
Offline
Joined: 2010-02-03
Points: 0

It's just a custom implementation of a Container at this point that I was hoping to be able to use in various places - Forms, Dialogs, etc.

vprise
Offline
Joined: 2003-11-07
Points: 0

myinstinct is correct ;-)
The reason this doesn't hold the entire screen is because you took the border layout container and stuck it into a flow layout, box layout or some other layout that only grants preferred size.

Placing anything in the CENTER of the border layout takes up available space, but the definition of available space depends on the layout of your parent.