Reputation: 321
I wanted to use images to replace buttons on kivy. On youtube what I've seen is people creating an Image widget as a child of the button. But whenever I do this the image becomes a lot smaller than it's native resolution. I've tried resizing it with size_hint but it just doesn't scale. What I've done is just create the the Image widget seperate from the buttons and matched up their size and positions. I'm just curious if this is the only way to go about it or is there a better way to do it.
What I tried to do based on youtube videos:
<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"
my "solution":
<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}
Upvotes: 0
Views: 293
Reputation: 78
allow_stretch is a better way:
Image:
source: "arrow1.png"
allow_stretch: True
Upvotes: 0