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?
Related
Flutter Listview component uses scrollDirection to do horizontal scrolling.
How do i set the width of the individual items to window width and scroll one page at a time?
You may want to use a PageView instead of a ListView as it works just like you described. It fits better your purpose because you don't have to write all the logic to manage the threshold of the pages and it automatically allocates the entire screen width for each element.
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)
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 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.