【问题标题】:How do I remove this Kivy Spacing problem如何消除此 Kivy 间距问题
【发布时间】:2021-04-16 22:09:22
【问题描述】:

我不明白如何正确设置间距。我需要第一个对象从顶部开始,并且我需要不要将单词捆绑在一起。

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'

【问题讨论】:

    标签: python kivy kivymd


    【解决方案1】:

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

    【讨论】:

    • 如果没有滚动视图...图像在顶部,就在它应该在的位置...当我添加滚动视图时...它会自动在图像和顶部之间添加巨大的空间吧...我尝试 pos_hint 并且它很固执...
    猜你喜欢
    • 1970-01-01
    • 2022-01-23
    • 1970-01-01
    • 1970-01-01
    • 2011-05-14
    • 1970-01-01
    • 1970-01-01
    • 2011-07-05
    • 2011-11-16
    相关资源
    最近更新 更多