Hultner
Hultner

Reputation: 3780

How do I get a Composite containing FlowLayout inside a ScrolledComposite to grow vertical and not horizontal?

I'm trying to create a Composite containing FlowLayout inside a ScrolledComposite so that the Composite inherits its width from the ScrolledComposite but grows in height dynamically. I've searched some snippets but I'm not getting them to work; I can only get it to grow in width which is not desirable.

What I'm trying to do is to create a View containing a bunch of thumbnails to fill the window/surrounding composite in width and scroll in height.

Upvotes: 1

Views: 381

Answers (1)

Waqas Ilyas
Waqas Ilyas

Reputation: 3241

You will need to override the computeSize method of the composite, or the FillLayout to always report back the given widthHint, unless perhaps the width hint is smaller than a single thumbnail's width in which case you might want to show horizontal scroll).

There could also a possibility that you add a resize listener to ScrollComposite and keep calling ScrollComposite#setMinSize() to ensure the composite inside only grows vertically.

Also are you using the correct type on FillLayout?

Upvotes: 0

Related Questions