KivyMD 导航抽屉是透明的

问题描述

所以,我试图将导航抽屉背景设置为纯色,但它不是...fuging...工作。大声笑我尝试在 MDNavigationDrawer 之前放置导航布局,但没有。它只是抛出一个错误代码为 .kv 格式。请尝试给我一个相同格式的解决方案。

<MainWindow>:
    name: "Main"

    MDNavigationDrawer:
        id: nav

        BoxLayout:
            orientation: 'vertical'
            spacing: '8dp'
            padding: '8dp'

            Image:
                source: 'defaultProfile.png'


            MDLabel:
                text: 'UserName'
                font_style: 'Subtitle1'
                size_hint_y: None
                height: self.texture_size[1] 
                    

            MDLabel:
                text: 'Edit Profile'
                font_style: 'Caption'
                size_hint_y: None
                height: self.texture_size[1]

            ScrollView: 
                MDList:
                    OneLineListItem:
                        text: 'My Profile'
                        
                        icon: 'account-circle'

                    OneLineListItem:
                        text: 'Calender'
                        IconLeftWidget:
                            icon: 'calender'

                    OneLineListItem:
                        text: 'Contacts'
                        IconLeftWidget:
                            icon: 'ballot'                  

                    OneLineListItem:
                        text: 'Groups'
                        IconLeftWidget:
                            icon: 'account-group'

                    OneLineListItem:
                        text: 'logout'
                        IconLeftWidget:
                            icon: 'logout'
                    



解决方法

好的!哈哈!我修好了男孩!!我做错的只是我的 navDrawer 没有放在我所有正常的屏幕内容之后。这是修复的样子。 :)

<MainWindow>:
    name: "Main"

    NavigationLayout:

        ScreenManager:



    BoxLayout:
        orientation: 'vertical'

        MDToolbar:
            title: "Menu"
            left_action_items: [['menu',lambda x: nav.toggle_nav_drawer()]]
            right_action_items: [['settings',lambda x: root.navigation_draw()]]
            elevation: 11

        MDTextField: 
            #hint_text: "Search"
            helper_text: "Search"
            helper_text_mode: 'on_focus'
            icon_right: "magnify"
            icon_right_color: app.theme_cls.primary_color
            pos_hint: {'center_x': 0.5,'center_y': 0.5}
            size_hint_x: None 
            width: 300



        MDLabel:
            text: 'News Feed Here'
            color: app.theme_cls.primary_color
            halign: 'center'

        MDBottomAppBar:
            MDToolbar:
                left_action_items: [['bell',lambda x: app.navigation_draw()]]
                right_action_items: [['message',lambda x: app.navigation_draw()]]
                elevation: 11
                icon: 'desk'
                on_action_button: app.navigation_draw()

    MDNavigationDrawer:
        id: nav

        BoxLayout:
            orientation: 'vertical'
            spacing: '8dp'
            padding: '8dp'

            Image:
                source: 'defaultProfile.png'


            MDLabel:
                text: 'UserName'
                font_style: 'Subtitle1'
                size_hint_y: None
                height: self.texture_size[1] 
                    

            MDLabel:
                text: 'Edit Profile'
                font_style: 'Caption'
                size_hint_y: None
                height: self.texture_size[1]

            ScrollView: 
                MDList:
                    OneLineListItem:
                        text: 'My Profile'
                        
                        icon: 'account-circle'

                    OneLineListItem:
                        text: 'Calender'
                        IconLeftWidget:
                            icon: 'calender'

                    OneLineListItem:
                        text: 'Contacts'
                        IconLeftWidget:
                            icon: 'ballot'                  

                    OneLineListItem:
                        text: 'Groups'
                        IconLeftWidget:
                            icon: 'account-group'

                    OneLineListItem:
                        text: 'Logout'
                        IconLeftWidget:
                            icon: 'logout'