我是新来kivy,我要创建我的Android应用程序基本的UI,我想下面的代码的时候,我首先要创建我的BoxLayout我的UI分为三个部分:标题部分,主体部分和图标部分,其实我问题是如何的大小和位置我的图标图像按钮
<MyLabel@Label>:
color: .8, .9, 0, 1
font_size: 32
text_size: self.width, None
size_hint_y: None
height: self.texture_size[1]
<MyBoxLayout>:
orientation: 'vertical'
BoxLayout:
size_hint: 1, .1
Label:
text: "Face-Reg"
font_size: 50
color: .8, .9, 0, 1
text_size: self.size
ScrollView:
size_hint: 1, .8
MyLabel:
text: str ('Hello This is My New Project ' * 100)
BoxLayout:
size_hint: 1, .1
Button:
size_hint_x: 0.25
Image:
source: 'icon/server.png'
size:self.texture_size
Button:
size_hint_x: 0.25
Image:
source: 'icon/add.png'
size:self.texture_size
Button:
size_hint_x: 0.25
Image:
source: 'icon/recog.png'
size:self.texture_size
Button:
size_hint_x: 0.25
Image:
source: 'icon/renew.png'
size:self.texture_size
输出屏幕快照:1四个图标重叠在一起,也大小不匹配按钮的大小如何解决呢?谢谢
您可以调整size
和使用pos
的那些属性Image
。例如,这里是你会如何调整第三Button
:
Button:
id: b3
size_hint_x: 0.25
Image:
source: 'icon/recog.png'
allow_stretch: True
keep_ratio: False
size: b3.size
pos: b3.pos
注意分配给id
的Button
。这id
用于分配相同的大小和位置的Image
。所述allow_stretch: True
属性使得Image
拉伸以适合指定size
和keep_ratio: False
允许图像被不均匀地拉伸。详情请参见该Image
documentation。