python-3.xkivydialoglabelkivymd

How do I centre Kivymd's MDDialog title?


I'm trying to centre this MDDialog's title so it's in the middle. Apparently, there's no inbuilt method for doing that. Anyone know a way or a hack around it?

self.dialog = MDDialog(
                type = "custom",
                title = "Edit Profile Info",
                radius = [35, ] * 4,
                # change auto_dismiss back to True
                auto_dismiss = False,
                content_cls = content,
            )

        self.dialog.open()


Solution

  • If you use KivyMD version 2.0.1, you can use MDDialogHeadlineText to center the title, like this:

        self.dialog = MDDialog(
            MDDialogIcon(
                icon="refresh",
            ),
            MDDialogHeadlineText(
                text="Edit Profile Info",
            ),
            content,