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 items for which views are created via a ViewProvider. Based on the priority of the items, 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 indicator ViewProvider can be provided 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 items 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.
Note: At the moment this layout creates/inflates views for all items. The only exception is when ttMaxItems is set, then the number of items is limited to this. If the number of items is large with respect to the number of items that are shown, one can consider setting the ttMaxItems to prevent performance overhead spent on creating views that never would be shown.
Parameters
The display context.
The attribute set provided in the layout XML file.
The default style attribute set.
The type of items used to populate the child views in the layout.
Constructors
Properties
The Prioritizable items used to populate each child of this view.
The maximum number of Prioritizable items in this priority layout. When provided, limits the number of items considered to be displayed.
The listener that will be invoked when the overflowing items 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 content used to populate the overflow indicator in the view.
Optional ViewProvider that is used to create the view for the overflow indicator.
The ViewProvider that is used to create views for the priority items.