FMX firemonkey how to Scroll a vertical scroll box in runtime - delphi

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.

Related

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.

ScrollBox does not scroll

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.

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.

How do I keep a control at the bottom or right of a panel when the panel changes size?

There have been a few similar questions with solutions, but none answered my question, so here it is.
Making a TPanel collapse/expand with a TButton on it is ridiculously simple, or so I thought. I played around and by putting the button at the very top (for expansion/collapse of height from top to bottom) or left (for expansion/collapse of width from left to right) everything worked as planned. In fact all of the expandable/collapsible "advanced" panels work in the exact same way - the button is placed on top or left only. Soon enough I hit a wall: if you put the button at the bottom or right for expansion/collapse of height or width respectively, the buttons stay where they are on... the client area (?) - I lack the knowledge to explain this properly, but I'll presume that it is clear what is happening until otherwise pointed out. The point is that with the way I'm doing this the only solution would be to reposition the button within the panel, but that might put in on top of say some other components which should not be visible at all.
So the question is: how can I make this happen properly? as my idea of resizing the panel and then repositioning the button doesn't look like a proper approach to this problem. Alternatively, I'd gladly take some component that does this, however from the components that I have checked out, all act the same, even JEDI VCL TJvRollOut component can set Placement (of the button/caption) only to plTop or plLeft, so I'm thinking this isn't as simple to do?
Set to your button Anchors property to [akLeft, akBottom].
There are two properties for adjusting the alignment of any tool in delphi:
Align (alNone, alLeft, alRight, alTop....)
Anchors (akLeft, akRight, akTop, akBottom)
e.g.
You have a panel and drag a TEdit on the TPanel. Now, you want TEdit to occupy ONLY top-left corner of TPanel and its distance form the bottom and right corners of the panel should remain constant irrespective of changing the panel size (which means TEdit expands if you extent panel along the bottom or right corners).
Set Align-> alNone. (not alLeft or else tEdit would occupy entire left region on panel and not just top-left).
Set Anchors-> akLeft=akTop=akRight=akBottom=True.
In case you set akLeft=akTop=True and akRight=akBottom=False: then the size of TEdit remains constant on expanding panel along the bottom or right corners.

Controlling scroll viewer's scroll distance

I'm placing 20 textblocks in scroll viewer, but it scrolling upto 7? I also want to control the scroll distance in get scrolled whenever my application starts?
Probably, you set Height of ScrollViewer to Auto and it don't fit to screen. Set it to Parent Height. I hope it will work than.
Can you put up your code? Also make sure you have done these two things
1) Place it in a grid.row and set grid.rwo height to *
2) Do not place the scrollviewer in a stackpanel

Resources