Kivy:将按钮大小调整为RecyclerView大小

时间:2019-10-11 12:53:30

标签: python kivy

我开始学习Kivy。我想用水平RecycleView在左侧和Button在水平BoxLayout。 (类似于附图)。

enter image description here

我写了这段代码:

BoxLayout:
        RecycleView:
            id: imgs
            width: "200dp"
            viewclass: "Button"
            size_hint_x: None
            data: [{'text':"img"}, {'text': "img"}, {'text': "img"}, {'text': "img"}, {'text': "img"}, {'text': "img"}]

            RecycleBoxLayout:
                size_hint_y: None
                size_hint_x: None
                width: "200dp"
                height: self.minimum_height
                orientation: "vertical"


        Button:
            text: "IMAGE"

我希望RecyclerView中的按钮具有RecyclerView的宽度。
我试图使自己的按钮显示在RecyclerView中,但没有用。

有人知道如何拉伸按钮以填充RecyclerView的宽度吗?

最诚挚的问候

编辑: 我更改此行:

data: [{'text':"img"}, {'text': "img"}, {'text': "img"}, {'text': "img"}, {'text': "img"}, {'text': "img"}]

对此:

data: [{'text':"img img", 'width':200, 'size_hint_x':None}, {'text': "img"}, {'text': "img"}, {'text': "img"}, {'text': "img"}, {'text': "img"}]

然后第一个按钮具有RecyclerView的宽度。 所以我总是必须这样设置按钮的宽度吗?但是,是否有可能以某种方式在全球范围内这样做?

0 个答案:

没有答案