Kivy ScrollView 切断部分标签

Kivy ScrollView cutting off part of label

我目前在尝试将 GridLayout 与 ScrollView 结合使用时遇到问题,因为 GridLayout 中标签的上半部分被 ScrollView 截断了。 例如,这是它当前的样子:

而且,这是这部分的 .kv 代码(它是 BottomNavigation 的一部分):

MDBottomNavigationItem:
                id: hmNav
                name: 'home'
                text: 'Home'
                icon: 'home'
                GridLayout:
                    id: hmGrid
                    cols: 1
                    rows_minimum: {0: (self.parent.height) * 0.05, 1: (self.parent.height) * 0.2, 2: (self.parent.height) * 0.4, 3: (self.parent.height) * 0.1, 4: (self.parent.height) * 0.1}
                    row_force_default: True
                    MDLabel:
                        id: welcomeLabel
                        halign: 'center'
                        font_name: "DMSans"
                        text: "Hello, " + app.app.getId() + "!"
                        theme_text_color: "Custom"
                        font_size: '25sp'
                        size: self.texture_size
                        text_color: get_color_from_hex("#08421e")

                    MDLabel:
                        id: wLabel2
                        halign: 'center'
                        font_name: "DMSans"
                        text: "Here are your selected ingredients:"
                        theme_text_color: "Custom"
                        font_size: '15sp'
                        size: self.texture_size
                        text_color: get_color_from_hex("#08421e")

                    ScrollView:
                        id: selectedScroll
                        size: (self.parent.width, self.parent.height)
                        do_scroll_x: False
                        do_scroll_y: True
                        bar_width: 20

                        GridLayout:
                            id: selectedGrid
                            size_hint_y: None
                            spacing: 60
                            cols: 2
                            height: self.minimum_height
                            MDLabel:
                                halign: 'center'
                                text: "TEST1"
                                font_size: '15sp'
                                theme_text_color: "Custom"
                                text_color: get_color_from_hex("#08421e")
                                size: self.texture_size
                            MDLabel:
                                halign: 'center'
                                text: "TEST2"
                                font_size: '15sp'
                                size: self.texture_size
                            MDLabel:
                                halign: 'center'
                                text: "TEST1"
                                font_size: '15sp'
                                theme_text_color: "Custom"
                                text_color: get_color_from_hex("#08421e")
                                size: self.texture_size
                            MDLabel:
                                halign: 'center'
                                text: "TEST2"
                                font_size: '15sp'
                                size: self.texture_size
                            MDLabel:
                                halign: 'center'
                                text: "TEST1"
                                font_size: '15sp'
                                theme_text_color: "Custom"
                                text_color: get_color_from_hex("#08421e")
                                size: self.texture_size
                            MDLabel:
                                halign: 'center'
                                text: "TEST2"
                                font_size: '15sp'
                                size: self.texture_size

                    MDLabel:
                        halign: 'center'
                        text: "TEST 3"
                        font_size: '15sp'
                        size: self.texture_size

                    MDLabel:
                        halign: 'center'
                        text: "TEST 4"
                        font_size: '15sp'
                        size: self.texture_size

我已经成功地使用了带有 BoxLayout 的 ScrollView,使用与此 GridLayout 大部分相同的配置,但我不确定为什么顶部标签在这个特定实例中被切断。 任何帮助将不胜感激! 谢谢

当您在 GridLayout(和其他)中使用 height: self.minimum_height 时,它会根据其 height 计算 GridLayoutheight children。这意味着那些 children 必须具有明确的 height 值。您已经为每个 MDLabel 指定了 size: self.texture_size,但是如果 size_hint 保留为默认值 (1,1),那将没有任何效果。要修复它,只需添加:

size_hint_y: None

每个MDLabels