如何将一个小部件完全展开并缩小另一个小部件?

huangapple go评论62阅读模式
英文:

How to full expand one widget and shrink the other one

问题

我想在使用Fyne创建的Go应用程序中创建一个内联表单,其中包含一个Entry小部件和一个Button小部件。Entry小部件应占用所有可用空间,而Button小部件应缩小到其最小尺寸。我该如何做到这一点?

英文:

I would like to create an inline form with an Entry widget next to a Button widget in a go application created with Fyne. The Entry widget should take all the available space while the Button widget should shrink to its minimum size. How can I do that ?

答案1

得分: 2

边界布局(Border Layout)将使用中心位置的元素填充可用空间,并缩小边缘上的所有元素。要使用一个元素填充可用空间并缩小另一个元素,您可以将扩展的元素放在中心位置,将缩小的元素放在中心位置的所需位置(顶部、底部、左侧、右侧),并将所有其他边界设置为nil。

类似于这样:container.NewBorder(nil, nil, nil, button_widget, entry_widget)

英文:

The Border Layout will fill the available space using the element at center and shrink all elements on edges. To fill the available space with an element and shrink an other, you can put the expanded element at center, the shrunken element at the desired position from the center (top, bottom, left, right), and set all other borders to nil.

Something like this : container.NewBorder(nil, nil, nil, button_widget, entry_widget)

huangapple
  • 本文由 发表于 2023年6月14日 03:11:57
  • 转载请务必保留本文链接:https://go.coder-hub.com/76468032.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定