如何更改KivyMD底部导航的文本和图标颜色

时间:2020-07-28 08:49:23

标签: python android ios user-interface kivy

我已尝试遵循documentation来使用此小部件: text_color_normaltext_color_active,但它们不起作用。 :/

有人可以帮助我吗?’)

1 个答案:

答案 0 :(得分:1)

我遇到了同样的问题,唯一的解决方案是使用ThemeManager。

main.py

from kivymd.app import MDApp
from kivy.uix.screenmanager import Screen, ScreenManager
from kivymd.uix.label import MDLabel
from kivymd.theming import ThemeManager

class Main(MDApp):
    """docstring for Main"""
    def __init__(self):
        super(Main, self).__init__()
        self.screen     = Screen()
        self.sm         = ScreenManager()
        self.theme_cls  = ThemeManager()

    def build(self):
        #Enter the desired color instead of red
        self.theme_cls.primary_palette = "Red"

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

main.kv

Screen:
    ScreenManager:
        id: screen_manager
        Screen:
            name: 'home_screen'

            MDBottomNavigation:
                panel_color: rgba('262626')
                MDBottomNavigationItem:
                    icon: 'home'
                    text: 'home'