How to use List widget inside scroll container in fyne?

981 Views Asked by At

Scroll collapses everytime i use list widget inside scroll container, if i use label widget then scroll container is full width and full height but when i use list widget it just collapses.

Not Working (Scroll collapses)

func ShowListDialog(win fyne.Window, messages []string){
    list := widget.NewList(
        func() int {
            return len(messages)
        },
        func() fyne.CanvasObject {
            return widget.NewLabel("label")
        },
        func(i widget.ListItemID, o fyne.CanvasObject) {
            o.(*widget.Label).SetText(messages[i])
        },
    )
    d := dialog.NewCustom("Messages", "Close" , container.NewScroll(list), win) 
    d.Resize(fyne.NewSize(500, 400))
    d.Show()
}

Working for label (scroll has full width&height)

func ShowLabelDialog(win fyne.Window, message string){
    d := dialog.NewCustom("Message", "Close", container.NewScroll(widget.NewLabel(message)), win) 
    d.Resize(fyne.NewSize(500, 400))
    d.Show()
}
1

There are 1 best solutions below

5
On

The list widget already contains a scroll - removing the outer one should resolve your issue.