我如何解决这个 Kivy Spacing 问题

时间:2021-01-11 23:05:16

标签: python kivy kivymd

我不明白如何获得正确的间距。我需要第一个对象从顶部开始,并且我需要不要将这些词串在一起。

ScreenManager:
    id: screen_manager
    size_hint_y: 80
    Screen:
        name: 'Home'
    
        ScrollView:
            do_scroll_x: False
            do_scroll_y: True
            
            MDBoxLayout:
                cols: 1
                orientation: 'vertical'
                height: self.minimum_height
                size_hint_y: None
                scroll_type: ['bars', 'content']
                
                
                Image:
                    height: self.texture_size[1]
                    size_hint_y: None
                    keep_ratio: True                            
                    source: 'images/main.png'
                
                MDLabel:
                    size_hint_y: None
                    text: 'The Purest CBD'
                    halign: "center"
                    font_style: "H1"
                
                MDLabel:
                    size_hint_y: None
                    text: 'ThoughtCloud produces 100% organic, lab tested CBD oils made from hemp plants grown on licensed farms in the USA.'
                    halign: "center"
                    font_style: "H2"
                MDFlatButton:
                    text: "MDFLATBUTTON"
                    
                    
                Image:
                    height: self.texture_size[1]
                    size_hint_y: None
                    keep_ratio: True
                    allow_stretch: True
                    source: 'images/main.png'
                Image:
                    height: self.texture_size[1]
                    size_hint_y: None
                    keep_ratio: True
                    allow_stretch: True
                    source: 'images/main.png'

1 个答案:

答案 0 :(得分:0)

您可以使用 pos_hint 来确保您的小部件位于正确的位置。就像size_hint。您可以提供 0 到 1 之间的任何值以将您的小部件放置在正确的位置