簡體   English   中英

kivy 滾動布局問題

[英]kivy scroll layout issue

class Template_Screen (Screen):
    pass

以上是我添加到應用程序 class 中的 class 如下

class MAKE_HTML(App):
    """
    Still i need to write it fully.... Thanks for patience.....
    """
    def build(self):
        sm = ScreenManager()
        sm.add_widget(Template_Screen(name='Select Template'))

我正在使用如下的kv文件

#the below screen gives the template
<Template_Screen>
    ScrollView:
        do_scroll_y:True
        do_scroll_x: False
        GridLayout:
            size_hint_y:None
            cols:1
            height:self.minimum_height
            BoxLayout:
                Image:
                    source: "Images/Templates Pictures/Temp-1.png"
            Label:
                text:"Some sort of text\n Some text"

問題:

  1. 當我滾動時,即使我不向上滾動,滾動也會先滾動然后向上滾動。 即,向下滾動后-> 自動上升。
  2. 圖像不可見。 我希望圖像是屏幕大小的 1/2。

在此處輸入圖像描述

我想像 o/p 一樣滾動上面。

ScrollVieweffect_cls的默認值為DampedScrollEffect文檔將其描述為:

DampedScrollEffect:當前默認值。 允許用戶滾動超出正常邊界,但一旦釋放觸摸/單擊,內容 spring 就會返回。

這就是您看到的自動滾動效果。 您可以通過使用ScrollEffect作為effect_cls來消除該行為,但這也會阻止您在內容未填充ScrollView時滾動

當您對GridLayout使用height:self.minimum_height時,您必須為每個孩子提供一個height 由於您希望ImageScreen大小的一半,因此可以使用這樣的kv

#the below screen gives the template
<Template_Screen>
    ScrollView:
        do_scroll_y:True
        do_scroll_x: False
        effect_cls: 'ScrollEffect'
        GridLayout:
            size_hint_y:None
            cols:1
            height:self.minimum_height
            BoxLayout:
                size_hint: None, None
                size: root.width/2, root.height/2
                Image:
                    source: "mages/Templates Pictures/Temp-1.png"
                    allow_stretch: True
                    keep_ratio: True
            Label:
                text:"Some sort of text\\n Some text"
                size_hint: None, None
                size: self.texture_size

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM