【问题标题】:How to change text and icon colour of KivyMD’s Bottom Navigation如何更改 KivyMD 底部导航的文本和图标颜色
【发布时间】:2020-11-17 16:06:07
【问题描述】:

我已尝试关注此小部件的 documentationtext_color_normaltext_color_active 但它们不起作用。 :/

有人可以帮我吗:')

【问题讨论】:

    标签: python android ios user-interface kivy


    【解决方案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'
    

    【讨论】:

      【解决方案2】:

      您也可以导航到 kivymd/uix 然后打开底部导航。 py 并在第 273 行和第 289 行自定义 text_color 以将图标和标签设置为您想要的颜色,例如 1,1,1,1

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2020-02-25
        • 2019-05-07
        • 1970-01-01
        • 2020-02-02
        相关资源
        最近更新 更多