You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

KivyMD中使用MDBottomNavigation时MDList仅占半屏如何解决

问题原因

垂直排列的BoxLayout中,所有未明确设置高度约束的子组件会默认均分垂直空间,你的代码中ScrollView和MDBottomNavigation都没有指定高度规则,所以各自占了半屏。

解决方法

给底部导航栏设置固定高度,同时关闭它的高度自适应权重,这样ScrollView就会自动占满剩余的所有可用空间:

<CreateScreen>
    name: "create_screen"
    BoxLayout:
        orientation: "vertical"
        ScrollView:
            # 占满剩余全部高度
            size_hint_y: 1
            MDList:
                TwoLineAvatarIconListItem:
                    id: list1
                    text: "Date"
                    secondary_text: "Time"
                    IconLeftWidget:
                        icon: "github"
                        on_release: print("Hello")
                    IconRightWidget:
                        icon: "clock"


        MDBottomNavigation:
            # 关闭高度自适应,设置Material Design标准底部导航高度
            size_hint_y: None
            height: dp(56)
            MDBottomNavigationItem:
                name: 'screen 1'
                text: 'Back'
                icon: "arrow-left"
                on_tab_release: root.manager.current = "main_screen"


            MDBottomNavigationItem:
                name: 'screen 2'
                text: 'ADD'
                icon: "calendar-plus"
                on_tab_release: root.create_new_date_picker()

如果不需要严格遵循设计规范,也可以根据需求自行调整height的数值。

内容的提问来源于stack exchange,提问作者jzargo

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.10.04 22:45:04