Kivy widget positioning

0

I'm picking up Layout managers but I'm moving slowly.

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'

I get the following screen as a result:

Why does not B5 stay in the center like GridLayout since it's his son?

Thank you for your attention!

    
asked by anonymous 02.07.2018 / 19:01

1 answer

0

You need to define relative to what "B5" will position itself, so you need to define 'pos' of B5 as pos: self.x + 100, self.y + 100 for example that will be 100 pixels "in" of GridLayout

    
02.07.2018 / 19:09