rafaelcb21
rafaelcb21

Reputation: 13304

Kivy - Bottom and right position widget and margin

I'm trying to put the widget in the bottom and right position, with margin of 16dp, however I've tried it in a number of ways, with several layouts and it does not work. Can anybody help me?

ex35.py

from kivy.app import App
from kivy.core.window import Window
Window.clearcolor = (1, 1, 1, 1)

class Ex35(App):
    pass

Ex35().run()

ex35.kv

FloatLayout:
    BoxLayout:
        orientation:'vertical'
        Button:
            text:'Hello'
        Button:
            text:'Hello'
        Button:
            text:'Hello'
        Button:
            text:'Hello'
        Button:
            text:'Hello'
        Button:
            text:'Hello'
        Button:
            text:'Hello'
        Button:
            text:'Hello'

    Widget:
        id: ellipse
        size_hint: (None, None)
        size: (dp(56), dp(56))
        canvas:
            Color:
                rgba: 0, 1, 0, 1
            Ellipse:
                size: self.size

enter image description here

Upvotes: 0

Views: 1314

Answers (1)

rafaelcb21
rafaelcb21

Reputation: 13304

I got it with the code below:

FloatLayout:
    BoxLayout:
        orientation:'vertical'
        Button:
            text:'Hello'
        Button:
            text:'Hello'
        Button:
            text:'Hello'
        Button:
            text:'Hello'
        Button:
            text:'Hello'
        Button:
            text:'Hello'
        Button:
            text:'Hello'
        Button:
            text:'Hello'

    Widget:
        id: ellipse
        size_hint: (None, None)
        size: (dp(56), dp(56))
        pos_hint:{'right': 1}
        canvas.before:
            Color:
                rgba: 0, 1, 0, 1
            Ellipse:
                size: self.size
                pos: [dp(self.pos[0]) - dp(16), dp(self.pos[1]) + dp(16)]

enter image description here

Upvotes: 0

Related Questions