The StackLayout
widget refers to stacking boxes, so it stacks the widgets one over another In this recipe, we will stack four buttons of different sizes to see the behavior of the layout.
In this recipe, we will use the Python code similar to the code in the recipe Using the BoxLayout. I would recommend you to go through the preceding recipe.
In this recipe, we will use the KV file to set the StackLayout
and its children. The Python file is a code that we have been using in the layouts. Follow the next steps:
In the KV file, define a
StackLayout
child widget.Using the orientation property, give an orientation for stacking.
Define a button as a child of the
StackLayout
widget, which should be 50 percent of theStackLayout
widget's size.Using the following code, define four additional buttons as children of the
StackLayout
, each of 25 percent ofStackLayout
's size:<MyW>: StackLayout: orientation: 'bt-lr' Button: ...