TtSharedPriorityLayout
Takes priorities of all views in its own child TtPriorityLayouts into account to determine which views are visible when there is not enough space. Views with lower priorities among all TtPriorityLayouts will be hidden first when there is not enough space. This is useful in situations where multiple priority layouts compete for space in the same orientation. And when there is not enough space sometimes an item from one priority layout should disappear and sometimes from another.
Use this layout as direct parent layout of TtPriorityLayouts if priorities of views among TtPriorityLayouts need be considered together when the space is not enough to display them all. In order to share space, it is required that the sharing TtPriorityLayouts and this layout all have the same orientation. TtPriorityLayouts with a different orientation can be added, but will not be taken into account to share space. They will be treated as any other children as described below.
Next to TtPriorityLayout children, this layout may also contain other children. These other children always have higher priority than the views of the TtPriorityLayouts. If the space is not enough to show all other views, then the TtPriorityLayout will not occupy any space and the other views will be shown like in a normal LinearLayout. This layout ignores any layout_weight
assigned to TtPriorityLayout (layout_weight
will be treated as 0
, because its size gets measured based on priority rather than on weight). For other child views/layouts it works as usual.
Example:
<com.tomtom.tools.android.api.uicontrols.prioritylayout.TtSharedPriorityLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal" >
<com.tomtom.tools.android.api.uicontrols.prioritylayout.TtPriorityLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="horizontal"
ttElements="@{firstElements}" />
<View
android:layout_width="100dp"
android:layout_height="wrap_content"
android:layout_weight="1" />
<com.tomtom.tools.android.api.uicontrols.prioritylayout.TtPriorityLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="horizontal"
ttElements="@{secondElements}" />
</com.tomtom.tools.android.api.uicontrols.prioritylayout.TtSharedPriorityLayout>
Parameters
The display context.
The attribute set provided in the layout XML file.
The default style attribute set.