<Button>:
font_size: 20
size_hint: 0.2, 0.2
<RelativeLayoutWidget>:
BoxLayout:#站位
RelativeLayout:
Button:
text:"Btn0"
background_color: 0.1, 0.5, 0.6, 1
pos_hint: {"right":1, "top":1}
Button:
text:"Btn1"
background_color: 1, 0, 0, 1
pos_hint: {"x":0, "top":1}
Button:
text:"Relative"
background_color: 0.4, 0.5, 0.6, 1
pos_hint: {"center_x":.5, "center_y":.5}
Button:
text:"Btn2"
background_color: 0, 0, 1, 1
pos_hint: {"x":0, "y":0}
Button:
text:"Btn3"
background_color: 0.8, 0.9, 0.2, 1
pos_hint: {"right":1, "y":0}
from kivy.app import App
from kivy.uix.boxlayout import BoxLayout
class RelativeLayoutWidget(BoxLayout):
def __init__(self, **kwargs):
super().__init__(**kwargs)
class RelativeApp(App):
def build(self):
return RelativeLayoutWidget()
if __name__ == "__main__":
RelativeApp().run()
kivy学习完全解析 007 RelativeLayout 相对布局
最新推荐文章于 2022-10-20 09:53:32 发布