1

我现在正在构建一个应用程序,我想在那里实现 MDBottomSheet,但是有一个问题:底部表总是有一些额外的空白空间。

这是它的样子:

在此处输入图像描述

我很确定您可以看到“取消”按钮后有空白区域,我不知道如何解决。

这是我的一些 Python 代码:

from kivymd.app import MDApp
from kivymd.uix.bottomsheet import MDListBottomSheet

class MainApp(MDApp):
    def __init__(self, **kwargs):
        super().__init__(**kwargs)
    
    def screen_switch(self, scr_name):
        self.root.manager.current = scr_name
        self.root.toolbar.title = scr_name.capitalize()
        
    def open_bottom_sheet(self):
        bottom_sheet_menu = MDListBottomSheet(radius_from="top", radius=15)

        menu_items = [

            ("About the app", lambda x: self.screen_switch("About the app"), "help"),
            ("Leave a review", lambda x: self.screen_switch("Leave a review"), "email"),
            ("Cancel", lambda x: bottom_sheet_menu.dismiss(), "close")
            
        ]

        for txt, func, icon in menu_items:
            bottom_sheet_menu.add_item(txt, func, icon)

        bottom_sheet_menu.open()


这是我的一些 Kivy 代码:

BoxLayout:
    orientation: "vertical"

    toolbar: toolbar

    MDToolbar:
        id: toolbar
        type: "top"
        title: "Plans"
        right_action_items: [("dots-vertical", lambda y: app.open_bottom_sheet())]

提前致谢!

4

1 回答 1

1

我尝试了这种解决方法,它奏效了。在 open 语句之前插入以下行。

bottom_sheet_menu.sheet_list.ids.box_sheet_list.padding = (dp (16), 0, dp (16), 0)

希望它也适合你。

于 2021-08-13T14:29:34.507 回答