Max Layout

The layout.MaxLayout is the simplest layout, it sets all items in the container to be the same size as the container. This is not often useful in general containers but can be suitable when composing widgets

The max layout will expand the container to be at least the size of the largest item’s minimum size. The objects will be drawn in the order the are passed to the container, with the last being drawn top-most.

Now that we know how to lay out a user interface we will move on to the Widgets that are available to create your application.

Example Code

            
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
package main

import (
	"image/color"

	"fyne.io/fyne"
	"fyne.io/fyne/app"
	"fyne.io/fyne/canvas"
	"fyne.io/fyne/layout"
	"fyne.io/fyne/theme"
)

func main() {
	myApp := app.New()
	myWindow := myApp.NewWindow("Max Layout")

	img := canvas.NewImageFromResource(theme.FyneLogo())
	text := canvas.NewText("Overlay", color.Black)
	content := fyne.NewContainerWithLayout(layout.NewMaxLayout(),
		img, text)
	myWindow.SetContent(content)
	myWindow.ShowAndRun()
}