我正在尝试使用Kivy框架提供的KV lang创建一个接口。我想将两个 BoxLayout 小部件叠加在一起。渲染第一个布局时,它的默认高度为350.否则我需要将其缩小。
以下是我的布局
<RootWidget>:
# this is the rule for your root widget, defining it's look and feel.
StackLayout:
height: 350.0
BoxLayout:
id: 'letterBox'
height: 150.0
ActionButton:
width: 15.0
text: '-'
ActionButton:
width: 15.0
text: 'A'
ActionButton:
width: 15.0
text: 'B'
ActionButton:
width: 15.0
text: 'C'
ActionButton:
width: 15.0
text: 'D'
ActionButton:
width: 15.0
text: 'E'
ActionButton:
width: 15.0
text: 'F'
ActionButton:
width: 15.0
text: 'G'
ActionButton:
width: 15.0
text: 'H'
ActionButton:
width: 15.0
text: 'I'
ActionButton:
width: 15.0
text: 'J'
ActionButton:
width: 15.0
text: 'K'
ActionButton:
width: 15.0
text: 'L'
ActionButton:
width: 15.0
text: 'M'
ActionButton:
width: 15.0
text: 'N'
ActionButton:
width: 15.0
text: 'O'
ActionButton:
width: 15.0
text: 'P'
ActionButton:
width: 15.0
text: 'Q'
ActionButton:
width: 15.0
text: 'R'
ActionButton:
width: 15.0
text: 'S'
ActionButton:
width: 15.0
text: 'T'
ActionButton:
width: 15.0
text: 'U'
ActionButton:
width: 15.0
text: 'V'
ActionButton:
width: 15.0
text: 'W'
ActionButton:
width: 15.0
text: 'X'
ActionButton:
width: 15.0
text: 'Y'
ActionButton:
width: 15.0
text: 'Z'
BoxLayout:
id: 'contentBox'
height: 150.0
ActionButton:
text: '4'
答案 0 :(得分:1)
你可以做到。尝试使用size_hint,因为它使您的应用程序响应,在所有屏幕分辨率中看起来相似。
BoxLayout:
orientation: 'vertical'
BoxLayout:
id: 'letterBox'
size_hint: 1, .15
BoxLayout:
id: 'contentBox'
size_hint: 1, .85