1,1-06_size_hint_demo
![](https://images.cnblogs.com/OutliningIndicators/ContractedBlock.gif)
from kivy.app import App class WeatherApp(App): pass if __name__ == '__main__': WeatherApp().run()
![](https://images.cnblogs.com/OutliningIndicators/ContractedBlock.gif)
BoxLayout: orientation: "vertical" BoxLayout: Button: size_hint_x: 1 Button: size_hint_x: 1 Button: size_hint_x: 1 BoxLayout: Button: size_hint_x: 1 Button: size_hint_x: 2 Button: size_hint_x: 3 BoxLayout: Button: size_hint_x: 1 Button: size_hint_x: 0.75 Button: size_hint_x: 0.25
2, 滑动屏幕
![](https://images.cnblogs.com/OutliningIndicators/ContractedBlock.gif)
from kivy.app import App from kivy.uix.recycleview import RecycleView class ExampleViewer(RecycleView): def __init__(self, **kwargs): super(ExampleViewer, self).__init__(**kwargs) self.data = [{'text': str(x)} for x in range(20)] print('date=', self.data) class SampleApp(App): def build(self): return ExampleViewer() SampleApp().run()
![](https://images.cnblogs.com/OutliningIndicators/ContractedBlock.gif)
<ExampleViewer>: viewclass: 'Button' # defines the viewtype for the data items. orientation: "vertical" spacing: 40 padding: 10,10 space_x: self.size[0]/3 RecycleBoxLayout: color: '#008000' default_size: None , dp(56) # defines the size of the widget in reference to width and height default_size_hint: 0.4 , None size_hint_y: None height: self.minimum_height orientation: 'vertical' # defines the orientation of data items