开发者

How are margins and padding used in FireMonkey?

Does anyone know how to use the Margin and Padding fields?

Apparently the开发者_StackOverflow社区y can be used in place of Anchors, since FM doesn't support Anchors. I've been playing around with them this morning but couldn't get them to act in the way I wanted. eg, I would like two buttons to be anchored to the right and bottom of a form so that when the form is resized the buttons move with the form.


To do what you want, place a TLayout on your form and set its alignment to "bottom". Inside, you can place the two buttons you want to have.

Set the height of the Layout to the height of the buttons plus any margin you want the buttons to have from the edge of the form. Assume you want to stay 10 pixels away from the bottom and the right of the form, and a button is 25 pixels high, then the height of the layout is 35.

Set the right and bottom margin of the layout to 10, and then set the alignment of the rightmost button to "right". Give the rightmost button a left padding of, say, 15, and now set the alignment of the other button to "right" too. Now the buttons are right aligned in the layout, and the layout is bottom aligned to the form. In effect, the buttons will stay in the bottom right corner or the form.

                                         #
                                         #
 -------+--------+------------------+----#
        |        |H=25 (Button)     |    #H=35 (Layout)
        |   15   |                  | 10 #
 -------+ padd.  +------------------+    #
                 10 bot layout mrgn      #
 #########################################
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜