我正在使用KivyMD开发一个应用程序(至少正在尝试)。要导航,我想使用MDBottomNavigation。我的问题是我还想用MDToolbar显示标题,该标题“链接”到显示的内容。我的.kv文件如下所示:
BoxLayout:
orientation: 'vertical'
id: blayout
MDToolbar:
title: "1" if... else "2"
MDBottomNavigation:
id: navigation
MDBottomNavigationItem:
text: "xxx"
MDBottomNavigationItem:
text: "yyy"
我只是不知道在if和else之间插入什么,我想我必须检查显示的选项卡(使用id吗?),但是我不知道该怎么做,也没有任何线索。 / p>
答案 0 :(得分:1)
那是做到的方式:
BoxLayout:
orientation: 'vertical'
id: blayout
MDToolbar:
id: toolbar
title: "1"
MDBottomNavigation:
id: navigation
MDBottomNavigationItem:
text: "xxx"
on_tab_release: toolbar.title = "1"
MDBottomNavigationItem:
text: "yyy"
on_tab_release: toolbar.title = "2"