Search code examples
androidpythonkivykivy-language

Have Camera fill up parent box in Portrait mode


So currently I have the kivy code as this: : orientation: "vertical" display: entry padding: 10 spacing: 10

BoxLayout:
    size_hint: 1, 1
    id: entry
    multiline: False
    Camera:
        resolution: (640, 480)
        play: True

But I would like the camera to fill up the parent div and be in portrait mode. How would I go about achieving that?


Solution

  • Maybe you need to allow the video/image to stretch.

    Camera:
        allow_stretch: True
    

    To rotate the widget, you could also simply use a Rotate instruction:

    Camera:
        canvas.before:
            PushMatrix:
            Rotate:
                angle: 90
                origin: self.center
    
        canvas.after:
            PopMatrix:
    

    But then it's not correctly constrained by the parent (you need a way to invert width/heignt constraints).

    Something like:

    Widget:
        id: proxy
        Camera:
            center: self.size and proxy.center
            size: proxy.height, proxy.width
    
            canvas.before:
                PushMatrix:
                Rotate:
                    angle: 90
                    origin: self.center
    
            canvas.after:
                PopMatrix:
    

    Should do the trick.

    (can't test right now, on phone)