-
i want a layout with a list on top filling up the screen and some buttoms in a horizontal row at the buttom. i use this flow: myWindow.SetContent(container.NewVBox(
container.NewMax(
widget.NewList(
func() int {
return len(data)
},
func() fyne.CanvasObject {
return widget.NewLabel("template")
},
func(i widget.ListItemID, o fyne.CanvasObject) {
o.(*widget.Label).SetText(data[i])
})),
container.NewVBox(
layout.NewSpacer(),
container.NewHBox(
layout.NewSpacer(),
widget.NewButton("Yes", func() {
log.Println("Yes!")
}),
layout.NewSpacer(),
widget.NewButton("No", func() {
log.Println("No.")
}),
layout.NewSpacer(),
widget.NewButton("Maybe", func() {
log.Println("Maybe?")
}),
layout.NewSpacer(),
widget.NewButton("More..", func() {
log.Println("More..")
}),
layout.NewSpacer(),
)))) i expected the Max in the second line would extend the list to the remaining space above the buttons but it doesnt. if i replace the VBox in the first line with VSplit it works better, the List ist expanded to half of the screen. If i use Max in the first line the list is expanded as well (but fills the whole screen as documented). what would be the correct way to have the list above (y-wise) the buttons? |
Beta Was this translation helpful? Give feedback.
Replies: 5 comments 12 replies
-
The max layout does not do what you want it to do in this case. A container can only layout its items within its own area, not outside of it. The max layout basically allows you to stack items on top of each other, filling the space they are given, but they will not fill all the remaining space outside of the container. In this case, I expect that a border layout is more like what you want. You can place content at the edge positions and then the fifth argument will fill all the remaining space. I suggest reading through https://developer.fyne.io/explore/layouts and I especially think that you should have a look at https://www.youtube.com/watch?v=LWn1403gY9E as it should help getting a better understanding about how layouts and containers work. |
Beta Was this translation helpful? Give feedback.
-
the doc i see says:
no |
Beta Was this translation helpful? Give feedback.
-
i think the doc generally needs more links ;) i did not find the other doc you mention.. |
Beta Was this translation helpful? Give feedback.
-
ok, i changed my code to:
this does the trick! thank you! :) |
Beta Was this translation helpful? Give feedback.
-
yes, you are right, that can go too. |
Beta Was this translation helpful? Give feedback.
The max layout does not do what you want it to do in this case. A container can only layout its items within its own area, not outside of it. The max layout basically allows you to stack items on top of each other, filling the space they are given, but they will not fill all the remaining space outside of the container.
In this case, I expect that a border layout is more like what you want. You can place content at the edge positions and then the fifth argument will fill all the remaining space.
I suggest reading through https://developer.fyne.io/explore/layouts and I especially think that you should have a look at https://www.youtube.com/watch?v=LWn1403gY9E as it should help getting a be…