Float Layout — Kivy v1.0.1-dev documentation

# Float Layout

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

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 layout
    button = Button(text='Hello world')
    layout.add_widget(button)

    # if you want to create a button to be the 50% of the layout width, and 25%
    # of the layout height, and set position to 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 informations.

  `update_minimum_size`(*largs)

    Calculates the minimum size of the layout.