我有 Scrollable Grid Layout
在 Kivy 中,我试图在该 ScrollView 中添加图像,如下所示。我看不到它,我还试图使该图像根据屏幕分辨率动态更改其大小。
Screen:
name:"easy_1_1"
canvas.before:
Color:
rgba:0.2,0.3,0.4,1
Rectangle:
size:self.size
BoxLayout:
orientation:"vertical"
padding:20
spacing:10
ScrollView:
GridLayout:
size_hint: (1, None)
height: self.minimum_height
id: layout_content
cols: 1
spacing:10
padding:10
rows:3
Label:
text_size:self.size
text:"[b]What is Programming ?[/b]"
size_hint_y:None
valign: 'top'
font_size:"24sp"
color:1,1,1,1
markup:True
height:"100sp"
halign:"left"
halign:'center'
Label:
text_size:self.size
text:"test"*100
size_hint_y:None
valign: 'top'
font_size:"17sp"
color:1,1,1,1
markup:True
height:"660sp"
halign:"left"
halign:'center'
#PRoblem is here can not see the image
Image:
source:"aa.png"
Button:
text:"Back"
pos_hint_x:None
size_hint_y:None
height:"30dp"
background_normal: 'blue_with_finger.png'
background_down: 'bb1.png'
on_release:sm.current="easy_1"
如上面代码中所述,我无法在可滚动布局中添加图像...任何帮助将不胜感激。
最佳答案
尝试禁用 size_hint
(至少 y 部分)为您的图像:size_hint_y: None
您可能还需要定义一个 size 。size_hint
似乎不起作用(即使是默认的 1、1),但是,因为我没有使用过 GridLayout
,这可能是正常行为。
关于android - 如何在 Kivy 的 Scrollable GridLayout 中显示图像,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34952860/