【问题标题】:[Python][Kivy] Two Axes Scroll View in a Layout[Python][Kivy] 布局中的两个轴滚动视图
【发布时间】:2020-08-10 08:00:45
【问题描述】:

我对 Python 上的 Kivy 非常陌生,我正在尝试制作一个 android 应用程序。

由于我们的移动设备的尺寸不像我们在电脑上使用的屏幕那么大和宽,

我需要制作网格布局(表格),这应该同时滚动到 x 和 y 轴。

谁能给我一个很好的可执行示例?

ex)这就是我想要的。

App():
    Screen():
       ScreenVeiw(vertical and horizontal movement availability)
              GridLayout():
                   Labels():
           

非常感谢您的指导和支持!

希望大家有个美好的一天!

【问题讨论】:

    标签: layout kivy scrollview


    【解决方案1】:

    请在下面找到一个在 x 和 y 轴上都启用滚动的 GridLayout 工作示例:

    from kivy.app import App
    from kivy.lang import Builder
    
    APP_KV = """
    ScrollView:
        GridLayout:
            cols: 4
            size_hint: None, None
            height: self.minimum_height
            width: self.minimum_width
            row_default_height: 200
            col_default_width: 400
            Button:
            Button:
            Button:
            Button:
            Button:
            Button:
            Button:
            Button:
            Button:
            Button:
            Button:
            Button:
            Button:
            Button:
            Button:
            Button:
            Button:
            Button:
            Button:
            Button:
            Button:
            Button:
            Button:
            Button:
            Button:
            Button:
            Button:   
            Button:
    """
    
    class MainApp(App):
        def build(self):
            return Builder.load_string(APP_KV)
    
    if __name__ == '__main__':
        MainApp().run()
    

    【讨论】:

      猜你喜欢
      • 2018-03-26
      • 2017-12-09
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多