我尝试在Kivy中使用CardTransition。我想从右侧滑动“ OtherScreen”,然后当您返回时,它将向后滑动。我尝试使用“ push”和“ pop”作为模式
我尝试仅使用“推”功能,或者仅使用“ pop”功能,但我似乎无法将两者结合使用
'''
MainScreen:
name: 'main'
FloatLayout:
size: root.width, root.height
canvas.before:
Color:
rgba: 1, 1, 1, 1
Rectangle:
size: root.width, root.height
Button:
text: '2D'
size: root.height / 2.5, root.height / 2.5
size_hint: None, None
pos_hint: {'center_y': 0.75, 'center_x': 0.5}
on_press:
app.root.current = '2d'
root.manager.transition.direction = "left"
**root.manager.transition.mode = 'push'** *# this is push*
font_size: 50
background_normal: 'ok.png'
OtherScreen:
name: '2d'
FloatLayout:
size: root.width, root.height
Button:
on_press:
app.root.current = 'main'
root.manager.transition.direction = "right"
**root.manager.transition.mode = 'pop'** *# and this is pop*
text: 'back'
'''
单击第一个按钮后,“ OtherScreen”会滑入,但之后动画会完全消失
答案 0 :(得分:0)
CardTransition
不能按预期工作,因为在您的应用中,它在设置方向之前切换了屏幕。
on_press:
app.root.current = '2d'
root.manager.transition.direction = "left"
...
on_press:
app.root.current = 'main'
root.manager.transition.direction = "right"
on_press:
root.manager.transition.direction = "left"
app.root.current = '2d'
...
on_press:
root.manager.transition.direction = "right"
app.root.current = 'main'