Positioning of kivy widget

Asked

Viewed 332 times

0

I’m getting it from the layout managers but I’m slowly advancing.

I have this study code:

<Tela@RelativeLayout>:
    canvas.before:
        Color:
            rgb: 0,1,.05
        Rectangle:
            pos: [0.2*coord for coord in self.size]
            size: [0.6*coord for coord in self.size]

    GridLayout:
        size_hint: .5,.5
        pos_hint: {'center_x':.5,'center_y':.5}
        canvas.before:
            Color:
                rgb:.5,.3,.3
            Rectangle:
                pos: self.pos
                size: self.size

        Button:
            text: 'B5'

That gives me as a result the following screen: inserir a descrição da imagem aqui

Because B5 doesn’t stay in the center like Gridlayout since he’s his son?

Thank you for your attention!

1 answer

0

you need to define relative to what "B5" will position, so you need to define 'pos' of B5 as pos: self.x + 100, self.y + 100 for example it will be 100 pixels "inside" of Gridlayout

Browser other questions tagged

You are not signed in. Login or sign up in order to post.