admin管理员组文章数量:1417442
For some reasons only bottom bar is shown (independently of is_mobile
state). How can it be fixed?
BoxLayout:
orientation: 'vertical'
ActionBar:
hidden: app.is_mobile
size_hint_y: 0 if app.is_mobile else None
ActionView:
use_separator: True
ActionPrevious:
with_previous: True
on_release: app.next_screen('main')
ActionButton:
text: 'Shuffle 1'
ActionButton:
text: 'Check'
ActionButton:
text: 'Next'
Accordion:
AccordionItem:
title: '...'
Label:
text: '...'
AccordionItem:
title: '...'
Label:
text: '...'
ActionBar:
hidden: False if app.is_mobile else True
size_hint_y: None if app.is_mobile else 0
ActionView:
use_separator: True
ActionPrevious:
with_previous: True
on_release: app.next_screen('main')
ActionButton:
text: 'Shuffle'
ActionButton:
text: 'Check'
ActionButton:
text: 'Next'
where app_mobile is calsulated as:
from kivy.utils import platform
class MainApp(App):
is_mobile = BooleanProperty(False)
def build(self):
if platform in ['android', 'ios']:
self.is_mobile = True
For some reasons only bottom bar is shown (independently of is_mobile
state). How can it be fixed?
BoxLayout:
orientation: 'vertical'
ActionBar:
hidden: app.is_mobile
size_hint_y: 0 if app.is_mobile else None
ActionView:
use_separator: True
ActionPrevious:
with_previous: True
on_release: app.next_screen('main')
ActionButton:
text: 'Shuffle 1'
ActionButton:
text: 'Check'
ActionButton:
text: 'Next'
Accordion:
AccordionItem:
title: '...'
Label:
text: '...'
AccordionItem:
title: '...'
Label:
text: '...'
ActionBar:
hidden: False if app.is_mobile else True
size_hint_y: None if app.is_mobile else 0
ActionView:
use_separator: True
ActionPrevious:
with_previous: True
on_release: app.next_screen('main')
ActionButton:
text: 'Shuffle'
ActionButton:
text: 'Check'
ActionButton:
text: 'Next'
where app_mobile is calsulated as:
from kivy.utils import platform
class MainApp(App):
is_mobile = BooleanProperty(False)
def build(self):
if platform in ['android', 'ios']:
self.is_mobile = True
Share
Improve this question
asked Jan 31 at 11:39
FieryCatFieryCat
1,89921 silver badges28 bronze badges
2
|
1 Answer
Reset to default 1The ActionBar
and its children ActionButton, ...
have predefined sizes in the kivy style.kv
file. You can get what I believe are your desired results by working with those predefined properties. Try changing your kv
to:
BoxLayout:
orientation: 'vertical'
ActionBar:
hidden: app.is_mobile
# size_hint_y: 0 if app.is_mobile else None
opacity: 1.0 if not app.is_mobile else 0
height: '48dp' if not app.is_mobile else 0 # `480dp` is the default height from style.kv
ActionView:
use_separator: True
ActionPrevious:
with_previous: True
on_release: app.next_screen('main')
ActionButton:
text: 'Shuffle 1'
ActionButton:
text: 'Check'
ActionButton:
text: 'Next'
Accordion:
AccordionItem:
title: '...'
Label:
text: '...'
AccordionItem:
title: '...'
Label:
text: '...'
ActionBar:
id: ab
hidden: False if app.is_mobile else True
# size_hint_y: None if app.is_mobile else 0
opacity: 1.0 if app.is_mobile else 0
height: '48dp' if app.is_mobile else 0 # `480dp` is the default height from style.kv
ActionView:
use_separator: True
ActionPrevious:
with_previous: True
on_release: app.next_screen('main')
ActionButton:
text: 'Shuffle'
ActionButton:
text: 'Check'
ActionButton:
text: 'Next'
The height
property generally makes the ActionBar
visible or not. The opacity
property is used to make its children visible or not, because those children also have predefined sizes and will appear even if the ActionBar
has zero height
.
本文标签: pythonKivy Top or Bottom navigation barStack Overflow
版权声明:本文标题:python - Kivy: Top or Bottom navigation bar - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1745264460a2650514.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
is_mobile
isTrue
and whenis_mobile
isFalse
. – John Anderson Commented Jan 31 at 13:41