-2
有沒有什麼辦法可以實現一個按鈕浮動頂部所有其他的東西。例如,Reddit android應用程序有這樣一個按鈕。我不想用kivymd。kivy浮動按鈕android材質設計風格
有沒有什麼辦法可以實現一個按鈕浮動頂部所有其他的東西。例如,Reddit android應用程序有這樣一個按鈕。我不想用kivymd。kivy浮動按鈕android材質設計風格
您只需將您的內容放入FloatLayout中,並將該按鈕作爲FloatLayout的另一個子項,並將其指示爲所需的大小和位置。
FloatLayout:
BoxLayout:
orientation: 'vertical'
Label:
text: '1'
Label:
text: '2'
Label:
text: '3'
Label:
text: '4'
Button:
size_hint: None, None
right: self.width and root.right - 200
y: 200
text: 'such button'
但是,kivy如何知道浮動佈局中的哪一個元素在另一個之上?部件是否依次放置在浮動佈局中,因此在您的情況下,首先將BoxLayout放置並且之後可能位於Button的頂部? – PalimPalim
窗口小部件按照它們添加到父窗口的順序顯示(在kv中爲寫入順序),某些佈局(如BoxLayout)會阻止子窗口彼此重疊,FloatLayout不會。 – Tshirtman