gofyne

How to full expand one widget and shrink the other one


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 ?


Solution

  • 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)