MobileContainer with dynamic height in a MobileScrollableArea

Hi,

I have a MobileContainer which shows some product descriptions. As the length of the content is dynamic, the height of the container should be dynamic too.

As I embedded that container into a MobileScrollableArea, I saw that the controls below the description text move down correctly, but scrolling did not work.
So I assume that the height of the container does not automatically change when the controls move.

I’ve created a iOSLayoutConstraint to set the height but I only get this working with a fixed height.

Var contentConstraint As iOSLayoutConstraint
contentConstraint = New iOSLayoutConstraint(ScrollableArea1.Container, _
iOSLayoutConstraint.AttributeTypes.Height, _
iOSLayoutConstraint.RelationTypes.Equal, _
Nil, _
iOSLayoutConstraint.AttributeTypes.None, _
1, _
2000)

How can I set the height of the container to the value that is actually needed?

Thank you very much

In my customCell I have a DataLabel that has no height constraint so it expands in height depending on the content. Then in the data source for the table (which reaches to the bottom of the screen) I have the following:

Var bottomConstraint As New iOSLayoutConstraint( _
customCell, _                              ' firstItem
iOSLayoutConstraint.AttributeTypes.Bottom, _ ' firstAttribute
iOSLayoutConstraint.RelationTypes.Equal, _  ' relation
customCell.DataLabel, _                            ' secondItem
iOSLayoutConstraint.AttributeTypes.Bottom, _ ' secondAttribute
1.0, _                                      ' multiplier
10, _           ' gap
1000)                                       ' highest priority

customCell.AddConstraint(bottomConstraint)

Make sure you add the constraint with that last line.

works perfect. Thank you very much

That’s interesting. I usually use a min constraint on the control’s Height to make sure it expands. So you’re saying if I’m not using a Height constraint at all, it will also expand? I’m going to try this.

1 Like

Yes, I use this all the time instead of anally tweaking the height of a label to get the text to fit. Usually it’s a label above a table where the table top constraint is set to the label bottom.

It’s an undocumented feature of Label. Don’t remember how I found it.

One caveat, it completely screws up the layout of the screen in the IDE.

1 Like