Skip to content
Related Articles
Open in App
Not now

Related Articles

Python | RecycleView in Kivy

Improve Article
Save Article
Like Article
  • Last Updated : 30 Jan, 2020
Improve Article
Save Article
Like Article

Kivy is a platform-independent GUI tool in Python. As it can be run on Android, IOS, Linux and Windows, etc. It is basically used to develop the Android application, but it does not mean that it can not be used on Desktop applications.

Recycleview helps to deal with a large number of data items. Recycleview provides the user with the flexibility to scroll down or scroll-up the data displayed in the kivy application. You can also select multiple data items at once. Recycleview is memory efficient as compared to Listview.

To use RecycleView you have to first import it.

from kivy.uix.recycleview import RecycleView


# Program to explain how to use recycleview in kivy
# import the kivy module
from import App
# The ScrollView widget provides a scrollable view 
from kivy.uix.recycleview import RecycleView
# Define the Recycleview class which is created in .kv file
class ExampleViewer(RecycleView):
    def __init__(self, **kwargs):
        super(ExampleViewer, self).__init__(**kwargs) = [{'text': str(x)} for x in range(20)]
# Create the App class with name of your app.
class SampleApp(App):
    def build(self):
        return ExampleViewer()
# run the App

The .kv file for the above code

    viewclass: 'Button'  # defines the viewtype for the data items.
    orientation: "vertical"
    spacing: 40
    padding:10, 10
    space_x: self.size[0]/3
        color:(0, 0.7, 0.4, 0.8)
        default_size: None, dp(56)
        # defines the size of the widget in reference to width and height
        default_size_hint: 0.4, None 
        size_hint_y: None
        height: self.minimum_height
        orientation: 'vertical' # defines the orientation of data items


Above code generates a list of numbers in the range 0 to 20 which can be viewed by scrolling up and down.

My Personal Notes arrow_drop_up
Like Article
Save Article
Related Articles

Start Your Coding Journey Now!