ScrollBox does not scroll - delphi

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

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:
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:
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):
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:
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.
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.

Related

FMX firemonkey how to Scroll a vertical scroll box in runtime

Somebody can help me how to scroll a vertical scrollbar in firemonkey in runtime, there is a property scrollby, but it didnt work, I don't have any ideia how to solve it.
Thanks
There is no independent vertical scroll bar component in FMX. There are however several scroll box components. A TVertScrollbox (VSB) is one of them. If you use that, you can safely set VSB.Align := TAlignlayout.Client. The VSB never scrolls itself! It only scrolls the content if the content exceeds the vertical dimension of the VSB.
You can put a TLayout on the VSB, then set it's alignment to VertCenter, and it's Height to VSB.Height * 2. At runtime, the vertical scrollbar will appear, and you will be able to scroll the layout up and down. After this, you can adjust the position of the layout on the screen by calling the Scrollby and ViewPortPosition methods of the VSB.
Use a TScrollBox set TAlignlayout.Client then put the components inside the Tscrollbox and set them TAlignlayout.top and Done! When the content exceeds the vertical dimension the scroll will appear.
in delphi and C ++ Builder in FMX you can use ScrollBy (int, int); to move the scroll
Exemple:
this->ScrollBox->ScrollBy(0, - this->ScrollBox->Width);
I used a negative value because this will make the scroll move downwards following the pre-filling of items.

UI to stay horizontally centered on the screen while items are added / removed

I need a sort of horizontal container to stay horizontally centered on screen while items are added or removed.
I decided to use horizontal UIStackView with 'align horizontally in container'. Once I added an item to it (in design mode), it stopped being centered. Moreover the size on the stack view are well as size of child view are greyed out!
I agree that the stack view size is controlled automatically. But why can't I set up the sizes of child views?
If UIStackView in inappropriate in my case, what should I do?

Why are my autolayout constraints conflicting?

I have an app using scroll view on a page with numerous icons within that scroll view. I don't understand auto layout very well, but I have constrained every single icon to its current canvas value to the view (after measuring and placing each icon in the correct spot). Why are there still conflicts (188 to be precise) and unambiguous positions?
As an example of what I have done in case the above is not clear, I have placed an icon in the top left of the scroll view. I have then constrained that icon on top, bottom, left and right of its current canvas value from the view.
This extremely hard to explain without showing (as in "live-demonstrating"), but I'll give it a try:
Autolayout for Scrollviews works differently than you probably think. You can't simply specify where to place its contents in relation to its bounds like that. After all, the "canvas" of the scroll view determines its size from the content you scroll over, whereas the size of the actual scroll view (lets call it its viewport, or "window onto the canvas") is determined in a different way (for example by constraining it to the elements around it).
This the opposite of how autolayout works for other views, since they are usually constrained by the size of their parent (up to the top view of a view controller and/or the screen bounds).
What you want to do is add all your items in a single view. From the smallest known size, constrain them to one another. Finally their container has a size resulting from its contents, i.e. your items. This is then the size of the "canvas" of the scroll view, so add it and constrain its position somehow (for example centering it horizontally and vertically). Now, the actual size of the scroll view and its position should be constrained by elements surrounding it.
It might take some thinking and training, so maybe you will want to test around in a small training project that only has a limited number of views to figure it out.
Add scroll view on the screen with constraints to parent view
Add content inside of scroll view
Put constraints between added view and parent view (NOT SCROLL VIEW)

Delphi only allow horizontal Drag-and-Drop on TControlBar

I have a TControlBar aligned to the bottom of my main form (same width). The height of this Control Bar is fixed.
This Control Bar contains a number of TPanels, aligned horizontally (With matching heights). These panels contain various other components. I want to be able to move and rearrange these panels horizontally side-to-side but disallow vertical movement (fix Top of Panels).
How can I achieve this. I have tried setting the Anchors->akTop property for each Panel to true. But the panels sometimes move vertically as I try and drag them side to side.
I am using RAD studio XE4
Set RowSize to the Height of the ControlBar:
Specifies the height of the control bar's rows.
And set RowSnap to False:
Specifies whether controls are snapped to the control bar's rows when docked.
Use RowSnap to specify whether controls are snapped to the control bar's rows when docked. Controls that are snapped have their Top and Height properties set automatically to correspond to the control bar's rows.

RTL support for UIScrollView

I am dynamically adding UIButtons of varying sizes to a horizontal scroll view. These buttons are being laid out from right to left, and I am adjusting the content size accordingly. However when the content size becomes bigger than the size of the scrollview, I'm not able to scroll to the left to see what the rest of the content is, it simply bounces back. I can scroll all the way to the right, but the content there is empty. I want to invert the scrolling direction but I'm not sure how to do that.
What is the appropriate way to do this sort of thing?
That's because you're probably still adding the buttons to the left side of your entire content box (the content size is expanded to the right).
In order to support the RTL you're trying to achieve, you ought to keep your scrollview always scrolled to the right when you increase the content size, and move the buttons from their old frames, to the new ones moved towards right as much as you increased the size of the scrollview.
There's a bit of handywork included, so you might want to check into a custom scrollView implementation, either your own, or possibly a library, but I'm not sure if there is one already.

Resources