是否有其他人发现有时会忽略minimum_height值。这是一些示例代码。有时它的功能与其他时候的功能不同。我找不到这种行为的模式。要重新创建该问题,请运行代码,关闭它并再次运行。我通常需要不超过3次才能让问题出现。您应该看到的有时屏幕底部的按钮采用与字体大小匹配的最小高度,有时按钮采用默认高度100。
from kivy.app import App
from kivy.uix.gridlayout import GridLayout
from kivy.uix.boxlayout import BoxLayout
from kivy.uix.button import Button
from kivy.uix.label import Label
from kivy.app import runTouchApp
main_layout = BoxLayout(orientation="vertical")
filler_label = Label(text='Space Filler Label',halign='center',valign='middle',size_hint=(1,None))
filler_layout = GridLayout(cols=1,size_hint=(1,1))
filler_layout.bind(minimum_height=filler_layout.setter('height'))
filler_layout.add_widget(filler_label)
button_layout = GridLayout(cols=3,size_hint_y=None)
button_layout.bind(minimum_height=button_layout.setter('height'))
button1 = Button(text='Button1',size_hint_y=None)
button1.bind(texture_size=button1.setter('size'))
button2 = Button(text='Button2',size_hint_y=None)
button2.bind(texture_size=button2.setter('size'))
button3 = Button(text='Button3',size_hint_y=None)
button3.bind(texture_size=button3.setter('size'))
button_layout.add_widget(button1)
button_layout.add_widget(button2)
button_layout.add_widget(button3)
main_layout.add_widget(filler_layout)
main_layout.add_widget(button_layout)
runTouchApp(main_layout)