0

I'm having a ScrollBox object that Im inserting some objects in it with align:=TalignLayout.Bottom and parent:=scrollbox , the objects get inserted successfully but the scrollbox does not scroll or shows ScrollBars , any kind of help will be much appreciated , thnks for your concern

5
  • 2
    Can you provide a sample unit with FMX form code so we can reproduce your issue? Commented May 24, 2015 at 2:20
  • Is the property ShowScrollBars set to true? Commented May 24, 2015 at 7:12
  • yep it is set to , but since the elements inserted has Bottom align it doesnt scroll :/ Commented May 24, 2015 at 9:01
  • You really need to follow Jerrys request and provide an MCVE including the .fmx file so we get all properties right. See stackoverflow.com/help/mcve. Commented May 24, 2015 at 11:24
  • The docs explicitly says that you must not set the right/bottom anchor. Commented May 24, 2015 at 11:27

1 Answer 1

8

A scrollbox presents a view of its content where that content may be larger than the area contained by the visual area of the scroll box itself. So, for example:

enter image description here

If in the image above the black rectangle is the scrollbox and the green rectangle is the extent of the content, then the scrollbox will allow the user to scroll the lower part of the content into view using the scrollbars (blue).

If this content is scrolled so that some is now off the "top" of the scrollbox and some still extends beyond the "bottom" then you end up with:

enter image description here

With scrollbars set to automatic, then as long as there is content above or below the visible area of the scrollbox then the scrollbar will be presented to allow this scrolling to occur.

However, if the content is entirely contained within the scrollbox, then there is no content to scroll and so no scrollbars. The crucial fact is that alignment is relative to the visible area of the scrollbox. So for example, if all of the content is aligned to the top of the scrollbox (and does not extend beyond the bottom):

enter image description here

In your case, by setting the alignment to the bottom, you are ensuring that the content is positioned such that it is aligned to the bottom of the visible area of the scrollbox:

enter image description here

It bears repeating that the bottom of the scroll-box, for alignment purposes, is the bottom of the visible area of that scroll box, not the bottom of any "virtual area" that extends beyond the scroll box itself.

When working with a scrollbox you should treat the contents of that scrollbox as absolutely positioned. Any attempt to use relative positioning results in dynamic adjustments and is likely to run into problems as the scrollbox itself tries to dynamically adjust to accommodate any content.

If your layout needs demand bottom alignment relative to some other items then you could create a specific container for just those items.

In this case for example, you may have a single panel as an item in the scrollbox. Your items may then be aligned to the bottom of that panel, with the size of the panel determined (and set) at runtime according to the amount of additional space calculated as being required "above" those bottom aligned controls.

enter image description here

The scrollbox will then present the panel (the grey item) as scrollable, whilst your bottom alignment takes care of the layout of your items within that panel.

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.