Reputation: 127
I'm trying to use FloatLayout
in Kivy to manually position some images, but the origin point (0, 0)
seems to be at the center of the screen, and not the bottom left corner as described by the documentation. I've tried setting the pos
, pos_hint
, and left
properties of the image to get it in the bottom left corner, but nothing is working.
Frustratingly, when I draw a rectangle there with canvas.after
, it draws correctly in the bottom left corner. My kv code:
FloatLayout:
canvas.after:
Line:
rectangle: [0, 0, 10, 10]
Image:
id: sprite
pos_hint_x: None
pos_hint_y: None
pos: 0, 0
size: 32, 32
source: 'atlas://img/sprites/fuzzy_dragon'
The image draws dead center in the screen, with the rectangle in the bottom left corner. What am I doing wrong?
Upvotes: 2
Views: 661
Reputation: 12189
It's size_hint_*
, not pos_hint_*
for disabling relative sizing i.e.:
size_hint: None, None
size: 32, 32
otherwise it'll take the whole screen thus you think it's centered. Well, it is, but not for the reasons you think it is :P
pos_hint
is a dictionary and works differently.
In future debug layouts and elements with Inspector(python main.py -m inspector
).
Upvotes: 3