package com.codename1.ui.layouts

Layout managers allow a com.codename1.ui.Container to arrange its components by a set of rules that adapt to specific densities (ppi - pixels per inch). A layout manager is an arranging algorithm encapsulated by an abstract class implementation that places components absolutely based on the “hints” received.

Layout Managers that ship with Codename One

com.codename1.ui.layouts.FlowLayout is default layout manager, simple, flexible and with a few caveats.

com.codename1.ui.layouts.BorderLayout is ubiquitous thru Codename One code.

com.codename1.ui.layouts.BorderLayout can also behave differently based on the center behavior flag

com.codename1.ui.layouts.BoxLayout Y axis is a the work-horse of component lists

com.codename1.ui.layouts.BoxLayout X axis is a simpler replacement to flow layout and has grow/no grow variants.

com.codename1.ui.layouts.GridLayout arranges elements in a grid where all elements have an equal size. It can auto adapt the column count.

com.codename1.ui.table.TableLayout is similar in many regards to HTML tables. Notice that its in the com.codename1.ui.table package and not in this package.

com.codename1.ui.layouts.LayeredLayout is unique in the sense that it is meant to costruct layers and not the UI positions. It only lays out on the Z axis.

com.codename1.ui.layouts.GridBagLayout was added to Codename One to ease the porting of Swing/AWT applications.

com.codename1.ui.layouts.mig.MigLayout is a popular 3rd party layout manager its Codename One port is experimental.

Types

class BorderLayoutA border layout lays out a container, arranging and resizing its components to fit in five regions: north, south, east, west, and center.
class BoxLayoutLayout manager that places elements in a row (X_AXIS) or column (Y_AXIS) according to box orientation.
class CoordinateLayoutAllows laying out components based on absolute positions/sizes that are adapted based on available space for the layout.
class FlowLayoutFlowLayout is the default layout manager for Codename One Containers and Forms.
class GridBagConstraintsPort of the GridBag code from Apache’s Harmony
class GridBagLayoutCodename One port of the infamous GridBagLayout based on the Apache Harmony code.
class GridLayoutThe components are arranged in a grid based on available space, all cells in the grid are given exactly the same size which matches the largest preferred size or available space.
class GroupLayoutGroupLayout is a LayoutManager that hierarchically groups components to achieve common, and not so common, layouts.
class InsetsPort of Insets from Harmony for the use of the GridBag code
class LayeredLayoutThe LayeredLayout places the components in order one on top of the other and sizes them all to the size of the largest component.
class LayoutAbstract class that can be used to arrange components in a container using a predefined algorithm.
class LayoutStyleLayoutStyle is used to determine how much space to place between components during layout.
class TextModeLayoutThis is a special case layout specifically designed for com.codename1.ui.InputComponent.