How to make a portion of a Kivy screen scrollable
<p>I'm looking to make a page in Python using the Kivy library of the following format</p>

<pre><code>    ________________________
    |                      |
    |        title         |
    |______________________|
  &gt;&gt;|       Example 1      |&lt;&lt;
    |______________________|
    |           |          |
    |___________|__________|
    |           |          |
    |___________|__________|
    |           |          |
  &gt;&gt;|___________|__________|&lt;&lt;
    |         Home         |
    |______________________|
    |       Settings       |
    |______________________|         
</code></pre>

<p>The portion of the screen between the arrows should be scrollable. The code I have for this so far is as follows:</p>

<p>Kv file:</p>

<pre><code>&lt;ExampleScreen&gt;:
BoxLayout:
    orientation: 'vertical'
    Label:
        text: 'title'
    ScrollView:
        GridLayout:
            cols: 1
            Label:
                text: 'Example 1'
            GridLayout:
                cols: 2
                rows: 4
                Label: 
                    text: 'Filler'
                Label:
                    text: 'Filler'
                Label:
                    text: 'Filler'
                Label:
                    text: 'Filler'
                Label: 
                    text: 'Filler'
                Label:
                    text: 'Filler'
                Label:
                    text: 'Filler'
                Label:
                    text: 'Filler'
    Button: 
        text: 'Home'
        size_hint: 1, .1
        on_press: root.manager.current = 'home'
    Button:
        text: 'Settings'
        size_hint: 1, .1
        on_press: root.manager.current = 'settings' 
</code></pre>

<p>Py file:</p>

<pre><code>from kivy.uix.gridlayout import GridLayout
from kivy.uix.scrollview import ScrollView
from kivy.app import App
from kivy.uix.screenmanager import ScreenManager, Screen
from kivy.uix.button import Button
from kivy.lang import Builder

Builder.load_file('example.kv')

class ExampleScreen(Screen):
    pass

sm = ScreenManager()

sm.add_widget(ExampleScreen(name = 'example'))

class TestApp(App):
    def build(self):
        return sm

if __name__ == '__main__':
    TestApp().run()
</code></pre>

<p>I've tried implementing this several ways and nothing has worked. Does anyone else have experience with this/know if this is possible? Thanks for your help!</p>

<p>Yes it is possible, if you get the indentation and size hints right.<br>
<a href="https://kivy.org/docs/api-kivy.uix.scrollview.html" rel="nofollow">ScrollView doc</a>  </p>

<p>Try this:  </p>

<pre><code>&lt;MyLabel@Label&gt;:
    size_hint:1,None

&lt;ExampleScreen&gt;:
    BoxLayout:
        orientation: 'vertical'
        Label:
            text: 'title'
        ScrollView:
            size_hint: 1,None
            GridLayout:
                size_hint: 1,None
                height: self.minimum_height
                cols: 1
                MyLabel:
                    text: 'Example 1'
                GridLayout:
                    size_hint: 1,None
                    height: self.minimum_height
                    cols: 2
                    rows: 4                
                    MyLabel:
                        text: 'Filler' 
                    MyLabel:
                        text: 'Filler'
                    MyLabel:
                        text: 'Filler'
                    MyLabel:
                        text: 'Filler'
                    MyLabel: 
                        text: 'Filler'
                    MyLabel:
                        text: 'Filler'
                    MyLabel:
                        text: 'Filler'
                    MyLabel:
                        text: 'Filler'

        Button: 
            text: 'Home'
            size_hint: 1, .1
            on_press: root.manager.current = 'home'
        Button:
            text: 'Settings'
            size_hint: 1, .1
            on_press: root.manager.current = 'settings'
</code></pre>

python kivy kivy-language