如何在 BoxLayout 中将一个 kivy 小部件相对于另一个小部件居中?
How to center a kivy widget relative to an other in a BoxLayout?
他
我正在寻找一种使 TextInput 垂直居中的简单方法。伪 kv 代码如下所示:
ParamBox:
orientation: 'horizontal'
padding: 5
spaceing: 5
Button:
text: 'hello'
size_hint_x: 0.25
Slider:
size_hint_x: 0.5
TextInput:
size_hint_x: 0.25
size_hint_y: None
height: sp(32)
如果TextInput 画在底部,看起来不太好。目标是将其绘制为以滑块线为中心。有什么想法吗?
以下是您想要的吗?默认情况下,AnchorLayout 将 TextInput 居中。
ParamBox:
orientation: 'horizontal'
padding: 5
spacing: 5
Button:
text: 'hello'
size_hint_x: 0.25
Slider:
size_hint_x: 0.5
AnchorLayout:
size_hint_x: 0.25
TextInput:
size_hint_y: None
height: sp(32)
他
我正在寻找一种使 TextInput 垂直居中的简单方法。伪 kv 代码如下所示:
ParamBox:
orientation: 'horizontal'
padding: 5
spaceing: 5
Button:
text: 'hello'
size_hint_x: 0.25
Slider:
size_hint_x: 0.5
TextInput:
size_hint_x: 0.25
size_hint_y: None
height: sp(32)
如果TextInput 画在底部,看起来不太好。目标是将其绘制为以滑块线为中心。有什么想法吗?
以下是您想要的吗?默认情况下,AnchorLayout 将 TextInput 居中。
ParamBox:
orientation: 'horizontal'
padding: 5
spacing: 5
Button:
text: 'hello'
size_hint_x: 0.25
Slider:
size_hint_x: 0.5
AnchorLayout:
size_hint_x: 0.25
TextInput:
size_hint_y: None
height: sp(32)