2017-05-30 80 views
0

我試圖把這個部件放在底部和右側位置,邊距爲16dp,但是我已經通過多種方式嘗試了它,並使用了幾種佈局不行。有誰能夠幫助我?Kivy - 底部和右側位置部件和margim

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

+0

您是否試過'pos_hint'?你究竟是什麼意思是16dp的餘量?像從右下角16dp的空間? –

+0

Margim 16dp我在Ellipse中添加了'pos:(dp(16),dp(16))'。我沒有得到的是把Ellipse帶到底部 – rafaelcb21

回答

0

我用下面的代碼得到它:

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

相關問題