ScrollView#

#

Added in version 1.0.0.

ScrollView class equivalent. It implements Material Design’s overscorll effect and simplifies working with some widget properties. For example:

ScrollView#

ScrollView:
    canvas:
        Color:
            rgba: app.theme_cls.primaryColor
        Rectangle:
            pos: self.pos
            size: self.size

MDScrollView#

MDScrollView:
    md_bg_color: app.theme_cls.primaryColor

The stretching effect#

import os
import sys

from kivy.core.window import Window
from kivy import __version__ as kv__version__
from kivy.lang import Builder
from kivy.metrics import dp

from kivymd.app import MDApp
from kivymd import __version__
from kivymd.uix.list import (
    MDListItem,
    MDListItemHeadlineText,
    MDListItemSupportingText,
    MDListItemLeadingIcon,
)

from materialyoucolor import __version__ as mc__version__


MAIN_KV = '''
MDScreen:
    md_bg_color: app.theme_cls.backgroundColor

    MDScrollView:
        do_scroll_x: False

        MDBoxLayout:
            id: main_scroll
            orientation: "vertical"
            adaptive_height: True

            MDBoxLayout:
                adaptive_height: True

                MDLabel:
                    theme_font_size: "Custom"
                    text: "OS Info"
                    font_size: "55sp"
                    adaptive_height: True
                    padding: "10dp", "20dp", 0, 0

                MDIconButton:
                    icon: "menu"
                    pos_hint: {"center_y": .5}
'''


class Example(MDApp):
    def build(self):
        self.theme_cls.theme_style = "Dark"
        return Builder.load_string(MAIN_KV)

    def on_start(self):
        info = {
            "Name": [
                os.name,
                (
                    "microsoft"
                    if os.name == "nt"
                    else ("linux" if os.uname()[0] != "Darwin" else "apple")
                ),
            ],
            "Architecture": [os.uname().machine, "memory"],
            "Hostname": [os.uname().nodename, "account"],
            "Python Version": ["v" + sys.version, "language-python"],
            "Kivy Version": ["v" + kv__version__, "alpha-k-circle-outline"],
            "KivyMD Version": ["v" + __version__, "material-design"],
            "MaterialYouColor Version": ["v" + mc__version__, "invert-colors"],
            "Pillow Version": ["Unknown", "image"],
            "Working Directory": [os.getcwd(), "folder"],
            "Home Directory": [os.path.expanduser("~"), "folder-account"],
            "Environment Variables": [os.environ, "code-json"],
        }

        try:
            from PIL import __version__ as pil__version_

            info["Pillow Version"] = ["v" + pil__version_, "image"]
        except Exception:
            pass

        for info_item in info:
            self.root.ids.main_scroll.add_widget(
                MDListItem(
                    MDListItemLeadingIcon(
                        icon=info[info_item][1],
                    ),
                    MDListItemHeadlineText(
                        text=info_item,
                    ),
                    MDListItemSupportingText(
                        text=str(info[info_item][0]),
                    ),
                    pos_hint={"center_x": .5, "center_y": .5},
                )
            )

        Window.size = [dp(350), dp(600)]


Example().run()
https://github.com/HeaTTheatR/KivyMD-data/raw/master/gallery/kivymddoc/stretch_over_scroll_stencil.gif

API - kivymd.uix.scrollview#

class kivymd.uix.scrollview.StretchOverScrollStencil(*arg, **kwargs)#

Stretches the view on overscroll and absorbs velocity at start and end to convert to stretch.

Added in version 2.0.0.

Note

This effect only works with kivymd.uix.scrollview.MDScrollView.

If you need any documentation please look at dampedscrolleffect.

minimum_absorbed_velocity = 0#
maximum_velocity = 10000#
stretch_intensity = 0.016#
exponential_scalar#
scroll_friction = 0.015#
approx_normailzer = 200000.0#
duration_normailzer = 10#
scroll_view#
scroll_scale#
scale_axis = 'y'#
last_touch_pos#
clamp(value, min_val=0, max_val=0)#
is_top_or_bottom()#
on_value(stencil, scroll_distance)#
get_hw()#
set_scale_origin()#
absorb_impact()#
get_component(pos)#
can_stretch_touch(touch)#
convert_overscroll(touch)#
reset_scale(*arg)#
class kivymd.uix.scrollview.StretchOverScrollBehavior(*args, **kwargs)#

Shared overscroll-stretch setup for ScrollView-based widgets.

on_touch_down(touch)#
on_touch_move(touch)#
on_touch_up(touch)#
class kivymd.uix.scrollview.MDScrollView(*args, **kwargs)#

An approximate implementation to Material Design’s overscorll effect.

For more information, see in the DeclarativeBehavior and BackgroundColorBehavior and ScrollView classes documentation.