Welcome!

Welcome to the official BlackBerry Support Community Forums.

This is your resource to discuss support topics with your peers, and learn from each other.

inside custom component

Native Development

Reply
Developer
Posts: 16,842
Registered: ‎07-29-2008
My Device: Z10 LE, Z30, Passport
My Carrier: O2 Germany
Accepted Solution

ListView causes large empty area below.

I have a ListView with two entries and a Label below it.

The ListView causes a large empty area to be displayed below its two entriesm and i cannot figure out how to get rid of it.

I tried to set a negative padding or margin on the bottom, but to no avail.

When i replace the ListView with two LabelFields it works properly.

----------------------------------------------------------
feel free to press the like button on the right side to thank the user that helped you.
please mark posts as solved if you found a solution.
@SimonHain on twitter
Developer
Posts: 6,473
Registered: ‎12-08-2010
My Device: PlayBook, Z10
My Carrier: none

Re: ListView causes large empty area below.

I can't quite think of the use case for a ListView with only two items in it, both currently visible. I might have a better solution if I understood why you'd want that, but in any case, you can at least work around the problem for now by setting preferredHeight to something. If you know the height of each entry, you could just use that. Standard ones are 121 pixels, for now, I think, so "preferredHeight: 121 * 2" might work as a quick hack.

Peter Hansen -- (BB10 and dev-related blog posts at http://peterhansen.ca.)
Author of White Noise and Battery Guru for BB10 and for PlayBook | Get more from your battery!
Developer
Posts: 16,842
Registered: ‎07-29-2008
My Device: Z10 LE, Z30, Passport
My Carrier: O2 Germany

Re: ListView causes large empty area below.

I wanted the look from the listfield, i have settled for buttons now, with the preferredWidth set to 700.0 to get them take the full width, which is also a dirty hack.

In any case, a listfield with few entries should not take more space than the number of its entries.
----------------------------------------------------------
feel free to press the like button on the right side to thank the user that helped you.
please mark posts as solved if you found a solution.
@SimonHain on twitter
Developer
Posts: 6,473
Registered: ‎12-08-2010
My Device: PlayBook, Z10
My Carrier: none

Re: ListView causes large empty area below.

I think the ListView by default is designed to fill the available space, perhaps effectively as though it had preferredHeight: Infinity set.

I'm not certain the idea of the ListView auto-sizing to match N components is a good one. If you started it out with no items, it would vanish. If you added items, it would gradually expand. Generally I don't think that's behaviour people want for their ListViews (though with appropriate height and other settings you could probably get it to work that way if required).

Also note the leadingVisual property, which might need more space than a pair of items would. That's another case where you probably want it either to auto-fill the available space, or at least match whatever size you explicitly set, regardless of number of contained items.

Think of it as having spaceQuota set to a positive value...

What *I* would like is to have these auto-sizing behaviours actually documented in some clearer fashion, since I keep spending time reverse-engineering the behaviour of these things. I spent an hour yesterday trying to figure out why a Divider had a big space appearing above it. Turns out it effectively has topMargin and bottomMargin set to 20 by default, but that's not in the docs... same as however this ListView works, I guess. I mean, it does say "By default, the width and height are adjusted automatically to fill its parent container." but I'd like to know exactly how it is doing that (e.g. height = Infinity?) so that I could more readily override the behaviour when I wanted to.

Peter Hansen -- (BB10 and dev-related blog posts at http://peterhansen.ca.)
Author of White Noise and Battery Guru for BB10 and for PlayBook | Get more from your battery!
Developer
Posts: 16,842
Registered: ‎07-29-2008
My Device: Z10 LE, Z30, Passport
My Carrier: O2 Germany

Re: ListView causes large empty area below.

Maybe you can create a JIRA entry to improve the documentation and link it here, i'd vote on it.
----------------------------------------------------------
feel free to press the like button on the right side to thank the user that helped you.
please mark posts as solved if you found a solution.
@SimonHain on twitter
Highlighted
Developer
Posts: 526
Registered: ‎05-17-2009
My Device: 9900
My Carrier: ATT

Re: ListView causes large empty area below.

Simon if you want things to take up the full width you should use space quotas, something like this...

Container {
layout: StackLayout { orientation: LayoutOrientation.LeftToRight}
Button {
text: "hello"
layoutProperties: StackLayoutProperties { spaceQuota: 1.0 }
}
}

 

Like all of my posts