【发布时间】:2021-09-19 17:51:01
【问题描述】:
我想用图片来替换 kivy 上的按钮。在 youtube 上,我看到人们创建一个 Image 小部件作为按钮的子级。但是每当我这样做时,图像就会比它的原始分辨率小很多。我试过用 size_hint 调整它的大小,但它只是不能缩放。我所做的只是创建与按钮分开的图像小部件并匹配它们的大小和位置。我只是好奇这是唯一的方法还是有更好的方法。
我根据 youtube 视频尝试做的事情:
<MainGrid>:
FloatLayout:
#cols: 1
size: root.width, root.height
Button:
on_release: root.submit_button()
pos_hint: {"x":0.25,"top":0.8}
size_hint: 0.5, 0.2
Image:
source: "arrow1.png"
我的“解决方案”:
<MainGrid>:
FloatLayout:
#cols: 1
size: root.width, root.height
Button:
on_release: root.yt_button()
pos_hint: {"x":0.25,"top":0.8}
size_hint: 0.5, 0.2
background_color: 0,0,0,0
Image:
source: "arrow1.png"
pos_hint: {"x": 0, "y": 0.2}
【问题讨论】:
标签: python kivy kivy-language