强制Kivy小部件的方向为风景/人像

问题描述:

我正在开发一个应用程序,我希望ScreenManager的屏幕之一处于横向方向。我不希望它自己改变为垂直。截至目前,我所学到的只是buildozer.spec文件可以改变应用程序的方向。我想要的是改变小部件的方向。有没有办法做到这一点?强制Kivy小部件的方向为风景/人像

+0

在你的buildozer文件中可能使用'orientation = all'并在https://gist.github.com/rnixx/c60a744576866a7f1a42上试试 – SotirisTsartsaris

可以放置在散射结构的画面的内容,然后将其旋转:

test.kv:

ScreenManager: 

    Screen: 
     name: 'normal' 

     Grid 

    Screen: 
     name: 'flipped' 

     ScatterLayout: 
      do_rotation: False 
      do_scale: False 
      do_translation: False 
      rotation: 90 
      pos_hint: {'center_x': 0.5, 'center_y': 0.5} 
      size_hint: None, None 
      size: root.height, root.width 

      Grid 


<[email protected]>: 
    cols: 1 

    Button: 
     text: 'normal' 
     on_press: app.root.current = 'normal' 
    Button: 
     text: 'flipped' 
     on_press: app.root.current = 'flipped' 

main.py:

#!/usr/bin/env python2 
# -*- coding: utf-8 -*- 
from kivy.app import App 


class Test(App): 
    pass 


Test().run() 

@edit 也有强化的Orientation