PYTHON + KIVYMD / KIVY |滚动视图仅在屏幕的一半上,但在导航抽屉中使用时可以正常工作
PYTHON + KIVYMD / KIVY | Scrollview is only on half the screen but works as normal when used in a navigation drawer
这是问题的图片。如您所见,左侧图片具有完全可用的滚动视图,而右侧图片仅在屏幕的下半部分显示滚动视图。
不确定这里出了什么问题。我试着来回移动意向水平,出于某种原因,它拒绝将任何东西放在赤道以上
Snippit of the KV code from the not working part:
Screen:
container: container
BoxLayout:
id: container
orientation: 'vertical'
MDToolbar:
title: "TRYM"
anchor_title: "center"
# right_action_items: [["check", lambda x: app.show_alert_dialog_save(), 'Save']]
left_action_items: [["keyboard-backspace", lambda x: app.show_alert_dialog_back(), 'Back']]
Widget:
ScreenManager:
id: screen_manager
Screen:
name: 'innlogget_trym_alarm'
id: trym
MDBottomNavigation:
MDBottomNavigationItem:
name: 'alarm_trym'
text: 'Alarm'
icon: 'alarm'
on_tab_release: text: 'Alarm'
MDLabel:
text: 'Currently no alarm active'
pos_hint: {"center_x": .5, "center_y": .8}
halign: 'center'
MDFloatingActionButton:
id: trym_time_picker
name: 'trym'
icon: "alarm-plus"
opposite_colors: False
elevation_normal: 8
pos_hint: {"center_x": .9, "center_y": .2}
on_release:
app.show_time_picker('trym')
MDBottomNavigationItem:
name: 'instillinger_trym'
text: 'Instillinger'
icon: 'tools'
# on_tab_release: screen_manager.current = "settings_list_view"
MDLabel:
ScrollView:
MDList:
OneLineIconListItem:
text: "Oppgrader til premium"
on_release:
print("Click!")
IconLeftWidget:
icon: "lock-outline"
TwoLineIconListItem:
text: "Tilkoblingsinnstillinger"
secondary_text: "Endre IP og port for klientsiden"
on_release:
app.show_confirmation_dialog()
IconLeftWidget:
icon: "lan-connect"
TwoLineIconListItem:
text: "Alarminstillinger"
secondary_text: "Konfigurer forsinket eller for tidlig handling"
on_release:
print("Click!")
IconLeftWidget:
icon: "account-clock"
工作部分的 KV 代码片段:
MDNavigationDrawer:
id: nav_draw
orientation: "vertical"
padding: "8dp"
spacing: "8dp"
AnchorLayout:
anchor_x: "center"
size_hint_y: None
height: avatar.height
Image:
id: avatar
size_hint: None, None
size: "56dp", "56dp"
source: "untitled.jpg"
MDLabel:
halign: 'center'
anchor_x: "right"
text: "AnySched"
font_style: "Button"
size_hint_y: None
height: self.texture_size[1]
MDLabel:
text: ""
font_style: "Caption"
size_hint_y: None
height: self.texture_size[1]
ScrollView:
MDList:
OneLineAvatarListItem:
on_press:
nav_draw.set_state("close")
app.next_screen('trym')
text: "Trym"
IconLeftWidget:
icon: "account-box"
OneLineAvatarListItem:
on_press:
nav_draw.set_state("close")
screen_manager.current = "lucas"
所以我发现了问题(张贴以防其他人遇到同样的问题)。
屏幕:
容器:容器
盒子布局:
编号:容器
方向:'vertical'
MD工具栏:
标题:“尝试”
anchor_title: "中心"
# right_action_items: [["check", lambda x: app.show_alert_dialog_save(), 'Save']]
left_action_items: [["keyboard-backspace", lambda x: app.show_alert_dialog_back(), 'Back']]
Widget: # <----- After removing this the ScrollView fills the whole screen not just half :)
ScreenManager:
id: screen_manager
Screen:
name: 'innlogget_trym_alarm'
id: trym
MDBottomNavigation:
这是问题的图片。如您所见,左侧图片具有完全可用的滚动视图,而右侧图片仅在屏幕的下半部分显示滚动视图。
不确定这里出了什么问题。我试着来回移动意向水平,出于某种原因,它拒绝将任何东西放在赤道以上
Snippit of the KV code from the not working part:
Screen:
container: container
BoxLayout:
id: container
orientation: 'vertical'
MDToolbar:
title: "TRYM"
anchor_title: "center"
# right_action_items: [["check", lambda x: app.show_alert_dialog_save(), 'Save']]
left_action_items: [["keyboard-backspace", lambda x: app.show_alert_dialog_back(), 'Back']]
Widget:
ScreenManager:
id: screen_manager
Screen:
name: 'innlogget_trym_alarm'
id: trym
MDBottomNavigation:
MDBottomNavigationItem:
name: 'alarm_trym'
text: 'Alarm'
icon: 'alarm'
on_tab_release: text: 'Alarm'
MDLabel:
text: 'Currently no alarm active'
pos_hint: {"center_x": .5, "center_y": .8}
halign: 'center'
MDFloatingActionButton:
id: trym_time_picker
name: 'trym'
icon: "alarm-plus"
opposite_colors: False
elevation_normal: 8
pos_hint: {"center_x": .9, "center_y": .2}
on_release:
app.show_time_picker('trym')
MDBottomNavigationItem:
name: 'instillinger_trym'
text: 'Instillinger'
icon: 'tools'
# on_tab_release: screen_manager.current = "settings_list_view"
MDLabel:
ScrollView:
MDList:
OneLineIconListItem:
text: "Oppgrader til premium"
on_release:
print("Click!")
IconLeftWidget:
icon: "lock-outline"
TwoLineIconListItem:
text: "Tilkoblingsinnstillinger"
secondary_text: "Endre IP og port for klientsiden"
on_release:
app.show_confirmation_dialog()
IconLeftWidget:
icon: "lan-connect"
TwoLineIconListItem:
text: "Alarminstillinger"
secondary_text: "Konfigurer forsinket eller for tidlig handling"
on_release:
print("Click!")
IconLeftWidget:
icon: "account-clock"
工作部分的 KV 代码片段:
MDNavigationDrawer:
id: nav_draw
orientation: "vertical"
padding: "8dp"
spacing: "8dp"
AnchorLayout:
anchor_x: "center"
size_hint_y: None
height: avatar.height
Image:
id: avatar
size_hint: None, None
size: "56dp", "56dp"
source: "untitled.jpg"
MDLabel:
halign: 'center'
anchor_x: "right"
text: "AnySched"
font_style: "Button"
size_hint_y: None
height: self.texture_size[1]
MDLabel:
text: ""
font_style: "Caption"
size_hint_y: None
height: self.texture_size[1]
ScrollView:
MDList:
OneLineAvatarListItem:
on_press:
nav_draw.set_state("close")
app.next_screen('trym')
text: "Trym"
IconLeftWidget:
icon: "account-box"
OneLineAvatarListItem:
on_press:
nav_draw.set_state("close")
screen_manager.current = "lucas"
所以我发现了问题(张贴以防其他人遇到同样的问题)。
屏幕: 容器:容器 盒子布局: 编号:容器 方向:'vertical' MD工具栏: 标题:“尝试” anchor_title: "中心"
# right_action_items: [["check", lambda x: app.show_alert_dialog_save(), 'Save']]
left_action_items: [["keyboard-backspace", lambda x: app.show_alert_dialog_back(), 'Back']]
Widget: # <----- After removing this the ScrollView fills the whole screen not just half :)
ScreenManager:
id: screen_manager
Screen:
name: 'innlogget_trym_alarm'
id: trym
MDBottomNavigation: