Implementation
The first step to getting started with ScrollView Widget is that you need first to import it.
from kivy.uix.screenmanager import ScreenManager, Screen

You can also try this code with Online Python Compiler
Run Code
Basic Method
After importing all the required modules follow the algorithm listed below:
1 import kivyApp
2 import Screen Manager, Screen, ""Transitions you want to use""
3 import Builder from kivy.lang “ To take input from file or given doc string”
4 Create Different Screen classes and pass them
5 Create features of Screen classes in .kv file
5.1 Add features on different screens
6 Create App class
7 return screen manager
8 Run an instance of the class
Note: The default ScreenManager.transition is a SlideTransition with options for direction and duration.
Python program
# import kivy app class
from kivy.app import App
# import app builder which build the .kv file or can also be used
# for using doc string to lay out the layout of our app
from kivy.lang import Builder
# importing the screen manager
from kivy.uix.screenmanager import (ScreenManager, Screen, NoTransition, SlideTransition, CardTransition, SwapTransition, FadeTransition, WipeTransition, FallOutTransition, RiseInTransition)
# You can create your kv code in the Python file
Builder.load_string("""
<ScreenOne>:
BoxLayout:
Button:
text: "Go to Screen 2"
background_color : 0, 0, 1, 1
on_press:
root.manager.transition.direction = 'left'
root.manager.transition.duration = 1
root.manager.current = 'screen_two'
<ScreenTwo>:
BoxLayout:
Button:
text: "Go to Screen 3"
background_color : 1, 1, 0, 1
on_press:
root.manager.transition.direction = 'left'
root.manager.transition.duration = 1
root.manager.current = 'screen_three'
<ScreenThree>:
BoxLayout:
Button:
text: "Go to Screen 4"
background_color : 1, 0, 1, 1
on_press:
root.manager.transition.direction = 'left'
root.manager.transition.duration = 1
root.manager.current = 'screen_four'
<ScreenFour>:
BoxLayout:
Button:
text: "Go to Screen 5"
background_color : 0, 1, 1, 1
on_press:
root.manager.transition.direction = 'left'
root.manager.transition.duration = 1
root.manager.current = 'screen_five'
<ScreenFive>:
BoxLayout:
Button:
text: "Go to Screen 1"
background_color : 1, 0, 0, 1
on_press:
root.manager.transition.direction = 'right'
root.manager.current = 'screen_one'
""")
# Create a class for all screens in which you can include
# helpful methods specific to that screen
class ScreenOne(Screen):
pass
class ScreenTwo(Screen):
pass
class ScreenThree(Screen):
pass
class ScreenFour(Screen):
pass
class ScreenFive(Screen):
pass
# creating the screen manger object
screen_manager = ScreenManager(transition = RiseInTransition())
screen_manager.add_widget(ScreenOne(name ="screen_one"))
screen_manager.add_widget(ScreenTwo(name ="screen_two"))
screen_manager.add_widget(ScreenThree(name ="screen_three"))
screen_manager.add_widget(ScreenFour(name ="screen_four"))
screen_manager.add_widget(ScreenFive(name ="screen_five"))
# Inheriting the property of App class in ScreenApp
class ScreenApp(App):
def build(self):
return screen_manager
# Running main
if __name__ == '__main__':
sample_app = ScreenApp()
sample_app.run()

You can also try this code with Online Python Compiler
Run Code
App Output

.

Frequently Asked Questions
What are Kivy widgets?
In Kivy, a Widget is the fundamental component of a graphical user interface. It comes with a canvas on which you may draw on the screen. It takes in information and responds to it.
What is Kivy Uix, exactly?
A module is kivy.uix. Widgets are part of the User Experience and are graphical user interface components. The kivy.uix module contains classes for creating and managing Widgets.
Is Kivy good for Android?
Kivy is a great tool for developing Android Apps. Kivy is an excellent tool for creating Android applications. The nicest thing about kivy is that it is cross-platform, which means that the same project can be used to create apps for iOS, Android, Windows, and OS X.
It does, however, have certain performance drawbacks (as do most cross-platform tools like unity, cocos etc).
What is Kivy's relative layout?
Relative Layout: This layout allows you to assign children relative coordinates. Use the FloatLayout if you want absolute placement. The RelativeLayout class is similar to the FloatLayout class, with the exception that its child widgets are positioned relative to the layout.
Conclusion
If you have reached here that means, you really enjoyed this article. This article covers the implementation of the Screen Manager widget in kivy with code snippets and their use cases. You might be interested in articles such as Floating Layout in Kivy, Carousel Layout in Kivy, Button Action in Kivy, Button Color in Kivy and Slider widget in Kivy.
Do upvote our blog to help other ninjas grow, and head over to our practice platform Coding Ninjas Studio to practise top problems, attempt mock tests, read interview experiences, and much more.
Happy Learning!