Kivy:如何在 RH 底角放置一个可调整大小的按钮,并留有间距?

Kivy: How do I place a resizable button in the RH bottom corner, with spacing?

我是 Kivy 的新手,想用它来开发移动 'Event Card' 应用程序。

我相信我已经完成了基本的布局,但是右下角的按钮让我望而却步。我尝试了各种方法来使按钮可调整大小并在其周围留有间距,但都无济于事。我的最大努力如下所示:按钮大小永远不会改变,填充也不会改变。后者是因为我看不到如何更改填充值 'on the fly'.

在此先感谢您的帮助。

chaosui.kv

#:kivy 1.10.0


<NextCardButton@MDRaisedButton>:
    size_hint: [None, None]
    size: [100, 100]
  
<EventCardLayout@BoxLayout>:
    orientation: "vertical"

<EventBottomLayout@AnchorLayout>:
    anchor_x: 'right'
    anchor_y: 'bottom'
    
    # To Do: 'padding' needs to be relative!
    padding: ('10dp', '10dp', '10dp', '10dp')

    adaptive_size: True

    MDRaisedButton:
    # To Do: move button to right.
        text: 'Next'
    

EventCardLayout:

    MDToolbar:
        title: "Events"
        right_action_items: [["menu", lambda x: app.callback(x)]]
        elevation: 10

    MDLabel:
        text: "Order"
        halign: "center"
        font_style: "H2"
        theme_text_color: "Secondary"

    MDLabel:
        text: "Enemy Spotted!"
        halign: "center"
        font_style: "H3"
        theme_text_color: "Primary"

    MDLabel:
        text: "Advance towards nearest opponent(s)"
        halign: "center"
        font_style: "H4"
        theme_text_color: "Primary"

    MDLabel:
        text: "Subordinate CR required to cancel order"
        halign: "center"
        font_style: "H5"
        theme_text_color: "Primary"

    EventBottomLayout:

chaosapp.py

from kivymd.app import MDApp
from kivy.lang import Builder
from kivy.metrics import dp
from kivymd.uix.menu import MDDropdownMenu


class ChaosApp(MDApp):
    def build(self):
        self.title = 'CHAnce Organising System'

        menu_items = [
            {
                "viewclass": "OneLineListItem",
                "text": f"{item}",
                "height": dp(56),
                "on_release": lambda x=f"{item}": self.menu_callback(x),
             } for item in ('Import', 'Shuffle', 'Reset', 'Abort')
        ]
        self.menu = MDDropdownMenu(
            items=menu_items,
            width_mult=4,
        )
        return Builder.load_file('chaosui.kv')

    def callback(self, button):
        self.menu.caller = button
        self.menu.open()

    def menu_callback(self, text_item):
        self.menu.dismiss()
        # Snackbar(text=text_item).open()


ChaosApp().run()

找到了!

size: .5 * self.parent.width, .5 * self.parent.height