I've created 4 "indicator buttons" and I've given all of them the same size_hint values, but they don't have the same size when I launch the program. Additionally I've created "validate buttons" (which also share the same size_hint values) and again, when I launch the program, they don't have the same size. Did I miss something? How exactly does size_hint work? (the indicator buttons are the large squares on the top right corner of the picture)
#indicators for the 1st row of buttons
Button:
id: i11
pos_hint: {"x": 0.2, "y": 0.7}
size_hint: 0.05, 0.065
background_normal: ""
background_color: root.colori11
Button:
id: i12
pos_hint: {"x": 0.18, "y": 0.7}
size_hint: 0.05, 0.065
background_normal: ""
background_color: root.colori12
Button:
id: i13
pos_hint: {"x": 0.16, "y": 0.7}
size_hint: 0.05, 0.065
background_normal: ""
background_color: root.colori13
Button:
id: i14
pos_hint: {"x": 0.14, "y": 0.7}
size_hint: 0.05, 0.065
background_normal: ""
background_color: root.colori14
#validate button
Button:
pos_hint: {"x": 0.66, "y": 0.725}
size_hint: 0.05, 0.065
text: "V"
on_release:
root.btn_action_v2()
I've done several Kivy layouts and have never once used pos_hint so my suggestion is to comment those away and see what result you get.
size_hint is a relative and so I have always used integers as I find those a bit easier to work with. Furthermore you have the option to use size_hint_x or size_hint_y individually
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.