如何在BoxLayout中使一个kivy小部件相对于另一个居中



Hej

我正在寻找一种简单的方法来居中一个文本输入垂直。伪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)

最新更新