Resizing Panels in proportion to form - forms

I am developing a Delphi game for my (grade 10) PAT.
I am using an image as a grid for my game and placing individual panels in each grid because I do not know how to use string grids as it's my first year with Delphi. When I place the panels perfectly in each grid of the image and run my code everything looks normal until I go full screen,then all the panels are in each grid but the size is not in proportion with the image as I placed it before.
A solution would be much appreciated.
Thanks in advance.

Use a TGridPanel in place of your image. Each panel goes into one cell of the grid, and with the column widths and row heights set as a percentage (which is the default), and both the grid and the panels in the grid having Align set to alClient, the cells, and therefore the panels, will adjust their size proportional to the entire form.

Related

Unity3d. UI elements snapping/anchoring

I have canvas with vertical layout and 2 elements within (in fact it's element with only recttransform on it, let's call it container). So these 2 containers take a half of the screen by height and stretched by width, ok. How can I place an text element in above container and snap it to the bottom of this container? I tried press bottom button in recttransform widget (also with shift and alt) and it seems it doesn't affect my transform at all
P.s. May be I can use some free plugin instead of default unity components of UI layout?
There are different ways of placing your UI elements
Simply drag and drop it to the bottom where you want it
Use the anchor widget to set the anchoring to bottom with horizontal stretch and hold shift to also set pivot. Then set Pos Y to 0. Set Left and Right to 0.
Assuming you also want other elements in your containers, place a Vertical Layout Group on each container and make sure that your text element is the last child of the container in the hierarchy.
I would also advise you to seek out tutorials on Unity UI anchoring, positioning, scaling, and layout. You need a deeper understanding of how these things interact than you are likely to get from Stack Overflow. Otherwise you will suddenly find that your UI behaves in unexpected ways when rearranged or displayed on a different aspect ratio.
It's fairly easy with Unity UI system. You just need to get used to it. Here are simple steps to accomplish what you want:
Create Text element as a child of that container.
Select your newly created element and edit its RectTransform component values:
2.1. Set both Y axis anchors (min and max) to 0.
2.2. Set pivot value to 0 as well.
2.3. Set Pos Y value to 0 as well.
Now your Text element is anchored at the bottom of the container and its position (and height) is measured from the bottom of the Text element itself.

overlapping elements in grid layout

In my game i add child object prefabs to a grid layout dynamically,
But the problem is when i do this the child objects overlap:
If i do this without code, the problem disappears but i want to do it through code.
instantiation code is fairly simple:
go = Instantiate(CardPrefab) as GameObject;
// go.GetComponent<Image>().sprite = card.GetSprite();
go.GetComponent<Image>().sprite = GC.GetSprite(1, card.GetIndex());
go.transform.GetChild(0).gameObject.SetActive(true);
go.transform.SetParent(GameObject.Find("Player1ScrollPannel").transform);
what is the solution?
there is nothing attached to my card prefab, just an image and a button as a child:
Note: I haven't really played with layout groups, but...
70 pixels times a scale of 8.34 results in a final size of 583.8, but you're asking your layout group to arrange things in 106 pixel-wide cells.
In pulling up Unity and shoving a few images with a high scale value into a layout group...I get the same behavior. You either need to remove the scale (1,1,1) or change the layout cell size.

Unity list item is leaving extra space in high resolution

I have a vertical Scroll List. I have developed this app for resolution 768*1024. In this resolution my List is working fine. But when I run my app in higher resolution(1440*2960) it leave some space around all 4 direction.
I have also tried with changing Layout element min height dynamically, but Spacing issue is still exist.
Vertical and horizontal layout set element position in (screen width/height divided by a number of elements) * element number, in other words, they space out all elements evenly across canvas space. To achieve what you want you either have to enable child control size -> height option or write a script that aligns your elements in the center of the screen and one after another taking in consideration their height.

Can't get vertical layout group with scrolling working

I've got a panel which sits above my canvas and slides out upon clicking a button. I want to populate this panel with several objects (the number will be determined at runtime). Since the number of objects can exceed the number that would reasonably fit on a single row of the panel, I'd like to be able to scroll down with the mouse to new rows where the remaining objects have been populated.
To achieve this I've put a Scroll Rect and a Mask on the panel, created a child Image with a Vertical Layout Group to hold a series of child panels representing the rows that would hold the objects, and set the Image as the Content of the Scroll Rect.
The issue is that when I try to make one of the row panels a child of the Image object by dragging it to the Image in the Hierarchy, the anchors for the panel coalesce to a single point (the top left of the Image since it is set to Upper Left alignment) and when I try to manually drag the anchors to the appropriate position a box with a red X in it appears and expands in a manner that doesn't seem to correspond to the direction of the mouse.
Is this the right approach, and if so, how can I get this to work?
Thanks!

Evenly aligning things in IB

I have ten labels on a view positioned vertically. I need to evenly space them. Does IB have any type of setting that will do this?
If you select individual labels and drag them around the view, they should "snap" to certain guides around the interface. If you drag an element close to another element it should snap to about 8 pixels away, and that's the standard spacing between elements on the iPhone.
If you want more precise control, you can select an element and use the arrow keys to move it around one pixel at a time.
You can also use the Align Horizontally/Vertically in Container menu items from the Layout menu.
Do the math and then type in the X,Y coordinates. Unfortunately, I think that is the easiest way.
If you are OK using Apple's guideline spacing, dragging one label near another will generate a dashed line at a certain point. Do this for each label below the next, and they will be evenly spaced.