首页 > 解决方案 > KivyMD 标签从顶部边界开始,滚动视图滚动总是回到初始位置

问题描述

有人可以告诉我我做错了什么吗?我花了几个小时试图弄清楚为什么我的标签从滚动视图的边界开始,以及为什么每次我释放触摸时我都不能正常滚动回到初始位置。请帮忙

WindowManager:

    HomeScreen:
        name: 'HomePage'
        BoxLayout:
            orientation: "vertical"
            size: root.width, root.height
            adaptive_height: True

        MDLabel:
            text: "Welcome to the first guide for Stella Arcana"
            font_size: "13sp"
            font_name:"SFProSB"
            halign: "center"

        MDFillRoundFlatButton:
            text: "Enter"
            font_style: "H6"
            text_color: 0, 0, 0, 1
            pos_hint: {"center_x": .5, "center_y": .10}
            elevation_normal: 10
            on_release:
                app.root.current = "FirstPage"
                app.root.transition.direction = "up"


    FirstScreen:
        name: 'FirstPage'
        BoxLayout:
            orientation:'vertical'
            size: root.width, root.height

            MDToolbar:
                title: "WHU"
                right_action_items: [["dots-vertical", lambda x: app.callback(x)]]
                font_name:"SFProSB"
                md_bg_color: .1, .1, .1, 0
    #                specific_text_color: 1, 1, 1, 1


            MDBottomNavigation:
    #                panel_color: .6, .8, 1, .5

                MDBottomNavigationItem:
                    name: 'screen 1'
                    text: 'Guide'
                    font_name:"SFProB"


                    GridLayout:
                        adaptive_height: True
                        adaptive_width: True
                        rows: 5
                        cols: 1

                        Button:
                            markup : True
                            text: '1. Classes : What to choose ?'
                            halign: 'center'
                            background_color: .5, .8, 1, .4
                            font_name:"SFProB"
                            font_size: "13sp"
                            on_release:
                                app.root.current = 'ClasseScreen'
                                app.root.transition.direction = "left"

                        Button:
                            markup : True
                            text: '2. Builds : Tank, DPS or Heal ?'
                            halign: 'center'
                            background_color: .5, .8, 1, .4
                            font_name:"SFProB"
                            font_size: "13sp"
                            on_release:
                                app.root.current = 'BuildsScreen'
                                app.root.transition.direction = "left"

                        Button:
                            markup : True
                            text: '[b]3. Donjon & Raids : Me gusta el pollo[/b]'
                            halign: 'center'
                            background_color: .5, .8, 1, .4
                            font_name:"SFProB"
                            font_size: "13sp"
                            on_release:
                                app.root.current = 'DungeonsScreen'
                                app.root.transition.direction = "left"

                        Button:
                            markup : True
                            text: '[b]4. Random : Random [/b]'
                            halign: 'center'
                            background_color: .5, .8, 1, .4
                            font_name:"SFProB"
                            font_size: "13sp"
                            on_release:
                                app.root.current = 'RandomScreen'
                                app.root.transition.direction = "left"

                        Button:
                            markup : True
                            text: "5. Idk : I really don't know"
                            halign: 'center'
                            background_color: .5, .8, 1, .4
                            font_name:"SFProB"
                            font_size: "13sp"
                            on_release:
                                app.root.current = 'TipsScreen'
                                app.root.transition.direction = "left"


                MDBottomNavigationItem:
                    name: 'screen 2'
                    text: 'Improve'
                    font_name:"SFProB"


                    MDLabel:
                        text: 'Here is how to Improve depending on class ect..'
                        font_name:"SFProB"
                        halign: 'center'

                MDBottomNavigationItem:
                    name: 'screen 3'
                    text: 'About Me'
                    font_name:"SFProB"


                    MDLabel:
                        text: 'About this app and his creator :'
                        font_name:"SFProB"
                        halign: 'center'

                    Button:
                        markup: True
                        text: ''
                        halign: 'center'
                        background_color: .5, .8, 1, .4
                        font_name:
                        font_size: root.width, root.height

    ClasseScreen:
        name:'ClasseScreen'

        AnchorLayout:
            anchor_x: 'center'
            anchor_y: 'top'
            orientation:'vertical'
            size: root.width, root.height

            MDToolbar:
                id: toolbar
                title: "S.A. : Pocket Guide"
                font_name:"SFProSB"
                md_bg_color: .1, .1, .1, 0
                type: "top"
                elevation: 10
                #NEED TO GET THE IMAGE OF ARROW LEFT BUTTON
                left_action_items: [["arrow_left.png", lambda x: root.back()]]

        ScrollView:
            do_scroll_x: False
            do_scroll_y: True
            size_hint: (0.85, 0.55)
            pos_hint: {'top': 1.0 - toolbar.height / self.parent.height}
            GridLayout:
                id: grid
                size_hint_y: None
                cols: 1
                row_default_height: '20dp'
                row_force_default: True
                spacing: 0, 0
                padding: 0, 0
                MDLabel:
                    text: """A boy and a girl were playing together. The boy had a collection of marbles. The girl has some \\sweets with her. The boy told the girl that he would give her all his marbles in exchange for the\\nsweets with her. The girl agreed.\\nThe boy kept the most beautiful and the biggest marbles with him and gave her the remaining marbles.\\nThe girl gave him all her sweets as she promised. That night the girl slept peacefully. But the boy\\ncould not sleep as he kept wondering if the girl has hidden some sweets from him the way he had\\nhidden the best marbles from her.\\nMoral of the Story :\\nIf you do not give 100 percent in a relationship, you will always kept doubting if the other person\\nhas given her / his hundred percent. This is applicable for any relationship like love, employee –\\nemployer, friendship, family, countries, etc…"""
                    font_size: '20sp'    

这是问题所在,我无法将标签设置为在工具栏后面开始

标签: pythonkivykivy-languagekivymd

解决方案


推荐阅读