Change the padding between items within list for Fyne

114 Views Asked by At

I have a list of items, where each item is made up of two rows.

I would like to reduce the padding between these two rows (for each item). I've tried to resize the final container but that did not work.

This is the code:

list := widget.NewListWithData(
        data,
        func() fyne.CanvasObject {
            row1Container := container.NewHBox(widget.NewLabel("Text 1"), layout.NewSpacer(), widget.NewLabel("Text 2"))
            row2Container := container.NewHBox(widget.NewLabel("Text 3"), layout.NewSpacer(), widget.NewLabel("Text 4"))

            // resize of the below container did not result in any change

            return container.New(layout.NewVBoxLayout(), row1Container, row2Container)
        },
        func(i binding.DataItem, o fyne.CanvasObject) {
            // ...etc
        })

Marked in red is the padding that I would like to reduce:

enter image description here

Please let me know how it can be done.

1

There are 1 best solutions below

0
andy.xyz On

The padding is part in the list (all containers and collection widgets use standard padding from the theme) and in the label you have used (which is the theme inner padding).

You can alter either of those in the theme, or you can use Text instead of Lable which does not try to align items with inner padding.

Or you can put the items into a container with a custom layout that reports a smaller MinSize than the label.