kivymd / KivyMD

KivyMD is a collection of Material Design compliant widgets for use with Kivy, a framework for cross-platform, touch-enabled graphical applications. https://youtube.com/c/KivyMD https://twitter.com/KivyMD https://habr.com/ru/users/kivymd https://stackoverflow.com/tags/kivymd
https://kivymd.readthedocs.io
MIT License
2.14k stars 655 forks source link

Layout of MDTopAppBar does not take effect (MDTopAppBarTrailingButtonContainer should locate to the far right but not work) #1708

Open lijiabin0930 opened 2 weeks ago

lijiabin0930 commented 2 weeks ago

Description of the Bug

Layout of MDTopAppBar does not take effect (MDTopAppBarTrailingButtonContainer should locate to the far right but not work)

Code and Logs

from kivymd.app import MDApp
from kivymd.uix.appbar import MDTopAppBar, MDTopAppBarLeadingButtonContainer, MDTopAppBarTitle, \
    MDTopAppBarTrailingButtonContainer, MDActionTopAppBarButton
from kivymd.uix.screen import MDScreen

class Example(MDApp):
    def build(self):
        title = MDTopAppBarTitle(
            text="Test",
        )
        # title.font_name = './SIMFANG.TTF'
        right = MDTopAppBarTrailingButtonContainer(
            MDActionTopAppBarButton(
                icon='calendar'
            ),
            MDActionTopAppBarButton(
                icon='attachment'
            ),
            MDActionTopAppBarButton(
                icon='dots-vertical'
            )

        )
        right.pos_hint = {
            'center_x': 1, 'center_y': 0.5
        }

        appbar = MDTopAppBar(
            MDTopAppBarLeadingButtonContainer(
                MDActionTopAppBarButton(
                    icon='menu'
                )
            ), title
            , right
        )
        appbar.pos_hint = {'x': 0, 'top': 1}
        appbar.type = 'small'
        appbar.size_hint = [1, 0.08]
        return MDScreen(
            appbar
        )

Example().run()

Screenshots

微信图片_20240608223805

Versions

lijiabin0930 commented 2 weeks ago

i try to change the font size of the MDTopAppBarTitle.font_size but it didn't work too

Dariosky-01 commented 2 weeks ago

I took a look and did some tests, even if I'm not an expert (and therefore for an objective working method it's always better to try and test what I publish even for you experts) I wasn't able to move the title, it always returns to the left, while the group of buttons on the right move to the right but not if they conflict with the text, and this happens if it is present at the same height, I noticed this when using appbar.type='large'. Changing this parameter brings it down and the buttons move to the right but not the title.

I did some tests because I'm making a summary of the problems I noticed in the various dependencies. I'll post something about it soon.