[Python] Can't set font_size for MDTextFieldHintText inside MDTextField

Discussão em 'Python' iniciado por Stack, Junho 10, 2025.

  1. Stack

    Stack Membro Participativo

    I'm using MDTextFieldHintText inside an MDTextField, but I can't change the MDTextFieldHintText font_size when it's nested. When I use MDTextFieldHintText outside of MDTextField, the font_size works as expected.

    The reason I'm trying to set a specific dp value is that when the user changes the system font size on their phone, the hint text gets distorted or doesn't properly fit within the MDTextField bounds.

    Does anyone have an idea or workaround for this issue?

    KV = """
    MDScreen:
    md_bg_color: self.theme_cls.backgroundColor

    MDTextFieldHintText:
    text: "font_size works here..."
    theme_font_size: "Custom"
    font_size: "40dp"

    MDTextField:
    mode: "outlined"
    theme_font_size: "Custom"
    font_size: "50dp"

    MDTextFieldHintText:
    text: "...but font_size doesn't work here"
    theme_font_size: "Custom"
    font_size: "40dp"
    """

    class MainApp(MDApp):
    def build(self):
    self.theme_cls.theme_style = "Light"
    screen = Builder.load_string(KV)
    return screen

    MainApp().run()


    (Kivy==2.3.1, KivyMD==development version from master branch)

    Continue reading...

Compartilhe esta Página