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.21k stars 663 forks source link

Positioning of MDTopAppBar elements #2 #1700

Open AHiXilTOr opened 4 months ago

AHiXilTOr commented 4 months ago

Description of the Bug

pos_hint: {"center_x": .5} doesn't work

Code and Logs

from kivymd.app import MDApp
from kivy.lang import Builder

kv = """
MDScreen:
    md_bg_color: self.theme_cls.secondaryContainerColor

    MDTopAppBar:
        type: "small"
        size_hint_x: .8
        pos_hint: {"center_x": .5, "center_y": .5}

        MDTopAppBarLeadingButtonContainer:

            MDActionTopAppBarButton:
                icon: "menu"

        MDTopAppBarTitle:
            text: "AppBar small"
            pos_hint: {"center_x": .5}

        MDTopAppBarTrailingButtonContainer:

            MDActionTopAppBarButton:
                icon: "account-circle-outline"
"""

class App(MDApp):
    def build(self):
        return Builder.load_string(kv)

App().run()
"""

class MainApp(App):
    def build(self):
        self.root = Builder.load_string(kv)

if __name__ == '__main__':
    MainApp().run()

Screenshots

333584429-86ae5ae8-2665-48a5-8985-04b59746f130

Versions

T-Dynamos commented 4 months ago

What is the use case of centering that icon?

It does not matches material design spec.

https://m3.material.io/components/top-app-bar/specs

(It does not declare anywhere to center icons)

AHiXilTOr commented 4 months ago

What is the use case of centering that icon?

It does not matches material design spec.

https://m3.material.io/comComponents/top-app-bar/specs

(It does not declare anywhere to center icons)

Not an icon, but a title.

WangZhongDian commented 3 months ago

I also encountered the same problem

nattokukun commented 2 months ago

I also encountered the same problem

jporta09 commented 2 months ago

I also encountered the same problem

theolaos commented 2 months ago

I also encountered the same problem

The problem seems to happen only when you try to center align the title. If you remove the alignment (pos_hint: {"center_x": .5}) Then everything works fine.

nattokukun commented 2 months ago

I see solved. thank you very much.