したがって、テキストがpos = (0,0)
とラベルが画面の中央に表示されます(あなたはサイズの視覚的な表現を持っているので、多分あなたは、最初のボタンでこれを試してみてください)私たちが持っていますpos_hint
取っ異なる引数(以下の説明はFloatLayout
の外のもののために正確ではないかもしれません): pos_hint:{"right":v1,"top":v2}
が(self.parent.right*v1 - self.width, self.parent.top*v2 - self.height)
にpos
を設定します - あなたは番目のtop
とright
を設定していますあなたが配置しているウィジェット。したがって、あなたのラベルは、(左下が0,0
であるため)、このような負のは、そのテキストが画面に表示されないこと
を調整し、その後、私たちは(あなたがあなたのケースのために、より便利かもしれません)pos_hint:{"x":v1,"y":v2}
を持っている、とpos_hint:{"center_x":v1,"center_y":v2}
ます。 pos
は、左下の座標のみを設定するので、サイズがどのように見えるかに影響することを頭に入れてどのように動作するかを把握することができます。
#:kivy 1.0.9
<test>:
#size: (500, 500)
#size_hint:(None, None)
canvas:
Color:
rgb: 1,0,0
Rectangle:
size: (5,5)
pos: (0,0)
Widget:
id:wig
pos: (250,250)
canvas:
Color:
rgb: 1,1,1
Rectangle:
size: (5,5)
pos: self.pos
Label:
id: boo
text:"boo"
color: 0,0,1,1
#size_hint:(1,1)
pos_hint:{"center_x":1,"center_y":1}
Label:
id: foo
text: "foo"
color: 0,1,0,1
#size_hint: (.6,.6)
pos_hint:{"x":1,"y":1}
Label:
id: bar
text:"bar"
color: 1,0,0,1
#size:(500,500)
#size_hint:(None, None)
pos_hint:{"right":1,"top":1}
#pos:100, 10
Button:
text:"goo"
size_hint:0.1,0.1
pos:(1,1)
#some debug info, i know the code is ugly
on_press: print self.parent.size,'\n', self.parent.right, self.parent.top, self.parent.x, self.parent.y, self.parent.center_x, self.parent.center_y, "\n","bar_right_top:", bar.pos,"foo_x_y:", foo.pos,"boo_center:", boo.pos, "\nwhite square:", wig.pos, "\n", bar.size, foo.size, boo.size