3

I have gotten some results trying to use TGridLayout to hold series of TImage object each with a bitmap loaded. However, there is no margin between the cotrols. I have already tried to make the TImage width/height smaller than TGridLayout itemheight/itemwidth, but no luck.

Example code:

ImageRef := TImage.Create(GridLayoutGallery);
ImageRef.Visible := False; // se true later
ImageRef.Width := GridLayoutGallery.ItemWidth - 10;
ImageRef.Height := GridLayoutGallery.ItemHeight - 10;
GridLayoutGallery.AddObject(ImageRef);
4

2 回答 2

4

您自己已经接近答案了,这就是我将如何实现这一目标:

假设您的网格包含一系列大小为 40 x 40 像素的图像

在此处输入图像描述

要在图像之间应用边距,只需将TGridLayout组件的ItemWidthItemHeight属性设置为大于实际图像大小的值,例如 42 x 42 像素。

在此处输入图像描述

这应该在放置在 TGridLayout 中的每个图像周围创建一个边距。

于 2013-07-28T14:46:34.950 回答
1

Look at the description of the TGridLayout: http://docwiki.embarcadero.com/Libraries/XE7/en/FMX.Layouts.TGridLayout

The children of a TGridLayout are resized to fit the sizes specified through the ItemHeight and ItemWidth properties. [...] However, you can customize sizes of child controls using the Margins properties of child controls. Image taken from Embarcadero

-> Set ItemHeight and ItemWidth to (ImageSize + MarginSize)
-> Set Margins of the images to (MarginSize)

于 2015-03-18T11:09:51.017 回答