簡述
根據官方解釋:
Transition where the new screen ‘falls’ from the screen centre, becoming smaller and more transparent until it disappears, and revealing the new screen behind it. Mimics the popular/standard Android. transition.
具體效果可參考本文中的影片
基本範例
在main.py中寫上此段程式碼:
from kivy.app import App from kivy.uix.screenmanager import ScreenManager, Screen, FallOutTransition from kivy.properties import ObjectProperty class AScreen(Screen): pass class BScreen(Screen): pass class sm(ScreenManager): a1 = ObjectProperty(FallOutTransition(duration=3)) class MyApp(App): def build(self): return sm() if __name__ == '__main__': MyApp().run()
在my.kv中寫上此段程式碼:
<AScreen>: name: 'menu' BoxLayout: Button: text: 'Goto settings' on_press: root.manager.current = 'settings' Label: text: str(root.transition_progress) <BScreen>: name: 'settings' BoxLayout: Label: text: str(root.transition_progress) Button: text: 'still settings' on_press: root.manager.current = 'menu' <sm>: transition: root.a1 AScreen: BScreen:
執行結果如下:
FallOutTransition使用技巧:
沒有
沒有留言:
張貼留言