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.
Related
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.
I have a TFlowLayout containing 5 same-sized controls. The TFlowLayout (with Align=Top) is a child of TVertScrollBox. When making the flowlayout smaller all 5 controls are displayed as one column. This works fine. However, when these 5 controls don't fit within the view then I would expect TVertScrollBox to kick in and provide the vertical scrolling capability.
It turns out that the TFlowLayout.Height property is not adjusted to a new height that corresponds with the height of the 5 controls displayed in that one column.
What would be the best way to provide vertical scrolling in this case?
I have an horizontal stack with three controls.
The first two (green and orange on the figure below) are based on IB_DESIGNABLE UIView classes. There are no width constrains inside these classes relatively to the width these controls have to be. The third view is a regular UIView.
These controls have multiple buttons. The buttons represent values for configurations. They are radio buttons used to let the user select a particular configuration between multiple. Because these buttons are used multiple times, a particular configuration may have just 4 options to choose, so I have to hide 3 buttons, in other cases 2 and so one.
These IB_DESIGNABLE classes are based on XIBs. The Buttons are inside horizontal stacks inside these XIBs.
This is the problem. Suppose I have to hide 2 buttons on the green one. Because both are inside a horizontal stack and their buttons are also inside an horizontal stack, when I hide one or more buttons from each one, I want the control to reduce its width.
In that case, by hiding 2 buttons of the green one I want the whole thing to be rendered like
But it is not. It is rendered like
NOTE: when the controls contract I need the third view to occupy the remaining space. I use that view to force the controls to the left, because I was unable to do that using just the stack, that were always trying to expand the whole thing.
None of these 3 views have constraints.
The buttons inside the XIB have horizontal constrains of width but they are using a priority of 750 instead of 1000.
The stack that holds the controls is horizontal, fill, fill, spacing 20.
The stack that holds the buttons inside the xib is horizontal, fill, fill, spacing 0.
Any ideas?
How do you hide the buttons? By isHidden=true? Then thats the reason. Autolayout ignores hidden state. The buttons are still there. You have to deactivate/change the constraints of the buttons too. e.g. set width constraint of the buttons to 0.
I have a ViewController which contains a ScrollView and I'm trying to make a form menu so I need multiple labels and text fields.
I've been using the designer to do that.
The ScrollView will allow the user to scroll vertically, I already have many elements in the View but I need to add more.
The problem is that the size of the parent ViewController have a fixed size in the designer and because of that I reached the situation where I need to add elements under a label but there is just no space in the designer where I can put it.
hmmm.. not sure how this will carry over to tamarin/visual-studio, but in Xcode Interface Builder you can set the View Controller Simulated Size to "Freeform" --- and then set it as tall as you wish. Well, it may have a limit, but I just tested it and made it as tall as 5,000 pts. After laying everything out, you can set it back to "normal" size. At runtime, it will size itself however you've set the constraints.
Other alternatives...
Design your elements in "containing" views, and then add them in either dynamically via code or by manually setting the positions in the designer.
Use a single, tall "containing" view in your Scroll View. Make that view, say, 1500 its tall. In the designer, add the first few elements, then set the Y position of that view to a negative number. If your Scroll View is 500 its tall, set the Y position of the containing view to -400. The view will "slide up" in the Scroll View, and you can continue adding elements.
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.