TtPriorityLayout
A LinearLayout that adjust its child views visibility according to the available space. The child views' priorities determine which views will be shown. The view with the lowest priority will be hidden first if the available space is not enough. When views share the same priority, the one that appears in ttContents first, will be prioritized to show.
To do so, this priority layout presents Prioritizable elements for which views are created via a ViewProvider. Based on the priority of the view models, corresponding views are shown until one does not fit. Starting from that one, the remaining views are hidden. Layout weight can be used to divide the remaining size between the visible children.
Child views are considered to be overflowed if there is not enough space for them. Optionally, an overflow layout can be provided in the ViewProvider.layoutProvider to show an overflow indicator child, which can be used to, for example, when clicked present a new view with the remaining items that could not be shown in the priority layout itself. These items can be listened to with the ttOnOverflowChanged listener.
When ttMaxItems is provided, only the ttMaxItems highest priority elements are considered to be displayed. Their order is the same order as defined in ttContents.
Note: At the moment this layout does not support attributes affecting the view positioning in child views, such as gravity in the orientation of this layout (if orientation is horizontal, then center_horizontal
is not supported), layout_margin
and padding
. Child views are attached/positioned to the layout from the start position sequentially.
Parameters
The type of view model used to populate the child views in the layout.
The display context.
The attribute set provided in the layout XML file.
The default style attribute set.
Constructors
Properties
The view models used to populate each element in the view.
The maximum number of child items of the layout. When provided, only this maximum number highest priority elements are considered to be displayed. Their order is the same order as defined in ttContents.
The listener that will be invoked when the overflowing contents change.
If an overflow indicator view is provided and there are overflow items, show the indicator view at the start of the layout or at the end.
The view model used to populate the overflow indicator element in the view.
The ViewProvider that is used to create views for the view models.