Float Layout

The FloatLayout class will just honor the Widget.pos_hint and Widget.size_hint attributes.

_images/floatlayout.gif

For example, if you create a FloatLayout with size of (300, 300):

layout = FloatLayout(size=(300, 300))

# By default, all widgets have size_hint=(1, 1)
# So this button will have the same size as
# the layout
button = Button(text='Hello world')
layout.add_widget(button)

# To create a button of 50% width and 25%
# height of the layout and positioned at
# 20, 20, you can do
button = Button(
    text='Hello world',
    size_hint=(.5, .25),
    pos=(20, 20))
# If you want to create a button that will always be the size of layout -
# 20% each sides
button = Button(text='Hello world', size_hint=(.6, .6),
                pos_hint={'x':.2, 'y':.2})

Note

This layout can be used to start an application. Most of time, you need to want which size is your Window.

Warning

If you are not using pos_hint, you must handle yourself the position of your childs. Mean if the float layout is moving, your must handle the moving childs too.

class kivy.uix.floatlayout.FloatLayout(**kwargs)

Bases: kivy.uix.layout.Layout

Float layout class. See module documentation for more information.