简体   繁体   中英

How to change text and icon colour of KivyMD’s Bottom Navigation

I have tried to follow the documentation for this widget: text_color_normal and text_color_active but they don't work. :/

Can someone please help me:')

I had the same problem and the only solution is to use 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'

You can also navigate to kivymd/uix then open bottom navigation. py and customize text_color on line 273 and 289 for icon and label to your desired color eg, 1,1,1,1

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM