Python 如何使用kivy提供更好的尺寸和pos提示
我目前正在为手机开发一款kivy应用程序。我有一些标签和按钮,如果我运行程序,它们的位置很好,但是当我缩小窗口时,标签和按钮中的文本会离开屏幕。有谁能建议更好的位置和尺寸提示,这样即使最小化窗口,他们也不会离开屏幕? 这是我的密码:Python 如何使用kivy提供更好的尺寸和pos提示,python,android,button,kivy,kivy-language,Python,Android,Button,Kivy,Kivy Language,我目前正在为手机开发一款kivy应用程序。我有一些标签和按钮,如果我运行程序,它们的位置很好,但是当我缩小窗口时,标签和按钮中的文本会离开屏幕。有谁能建议更好的位置和尺寸提示,这样即使最小化窗口,他们也不会离开屏幕? 这是我的密码: Label: color: 1,0,0,1 pos_hint:{ "top":5,"left": 1} size_hint:1,1 text: "Which number cannot be written in roman numb
Label:
color: 1,0,0,1
pos_hint:{ "top":5,"left": 1}
size_hint:1,1
text: "Which number cannot be written in roman numbers?"
font_size: 30
BoxLayout:
Button:
pos_hint:{"top": 1,"left": 1}
size_hint:1,1
text: "0"
font_size: 30
size: 30,30
on_release:
self.background_color = 250,255,0,0.3
Button:
pos_hint:{"top": 1,"left": 1}
size_hint:1,1
text: "1 million"
font_size: 30
size: 30,30
on_release:
self.background_color = 1, 0, 0, 1
BoxLayout:
Button:
pos_hint:{"top": 1,"left": 1}
size_hint:1,1
text: "999"
font_size: 30
size: 30,30
on_release:
self.background_color = 1, 0, 0, 1
Button:
pos_hint:{"top": 1,"left": 1}
size_hint:1,1
text: "10 million"
font_size: 30
size: 30,30
on_release:
self.background_color = 1, 0, 0, 1
在您的
标签
和按钮
中,您只需设置文本的大小,并根据需要缩短文本或向任意方向展开文本,例如:
Label:
text: 'this is some really long text which will be shortened to keep it inside the Label bounds'
text_size: self.size
shorten: True
shorten_from: 'right'
Label:
text_size: [self.parent.width, None]
size: self.texture_size
您可以对按钮使用相同的属性。
我猜您可以做的另一件事是根据需要展开标签
或按钮
,例如:
Label:
text: 'this is some really long text which will be shortened to keep it inside the Label bounds'
text_size: self.size
shorten: True
shorten_from: 'right'
Label:
text_size: [self.parent.width, None]
size: self.texture_size
在这里,当文本的水平大小变得太大时,文本将简单地增长到一个新行