我正在尝试使用 Fyne ( https://fyne.io/ )设置应用程序布局,但我遇到了一些问题;这是我的代码:
func main() {
myApp := app.New()
myWindow := myApp.NewWindow("Demo")
myWindow.SetMaster()
myWindow.SetPadded(false)
myWindow.Resize(fyne.NewSize(1024, 600))
//myWindow.SetFullScreen(true)
r1 := canvas.NewRectangle(color.RGBA{255, 0, 0, 255})
r1.SetMinSize(fyne.NewSize(1024, 110))
top := fyne.NewContainerWithLayout(layout.NewMaxLayout(), r1)
r2 := canvas.NewRectangle(color.RGBA{0, 255, 0, 255})
r2.SetMinSize(fyne.NewSize(1024, 400))
middle := fyne.NewContainerWithLayout(layout.NewMaxLayout(), r2)
message := widget.NewLabel("message")
messageWrap := fyne.NewContainerWithLayout(layout.NewCenterLayout(), message)
middle.AddObject(messageWrap)
r3 := canvas.NewRectangle(color.RGBA{255, 0, 255, 255})
r3.SetMinSize(fyne.NewSize(1024, 55))
bottom := fyne.NewContainerWithLayout(layout.NewMaxLayout(), r3)
data := widget.NewLabel("data")
dataWrap := fyne.NewContainerWithLayout(layout.NewCenterLayout(), data)
ua := widget.NewLabel("ua")
uaWrap := fyne.NewContainerWithLayout(layout.NewCenterLayout(), ua)
bottomWrap := fyne.NewContainerWithLayout(layout.NewBorderLayout(nil, nil, dataWrap, uaWrap), dataWrap, uaWrap)
bottom.AddObject(bottomWrap)
content := fyne.NewContainerWithLayout(layout.NewBorderLayout(top, bottom, nil, nil), top, bottom, middle)
myWindow.SetContent(content)
myWindow.ShowAndRun()
}
这是输出:
我是这个库的新手,我发现很难理解它是如何工作的;我需要删除布局中 , 和 块top
之间middle
的“填充”;bottom
有没有办法做到这一点?