RecycleView Layouts

New in version 1.10.0.

The Layouts handle the presentation of views for the RecycleView.

Warning

This module is highly experimental, its API may change in the future and the documentation is not complete at this time.

class kivy.uix.recycleview.layout.LayoutSelectionBehavior(**kwargs)[source]

Bases: kivy.uix.behaviors.compoundselection.CompoundSelectionBehavior

The LayoutSelectionBehavior can be combined with RecycleLayoutManagerBehavior to allow its derived classes selection behaviors similarly to how CompoundSelectionBehavior can be used to add selection behaviors to normal layout.

RecycleLayoutManagerBehavior manages its children differently than normal layouts or widgets so this class adapts CompoundSelectionBehavior based selection to work with RecycleLayoutManagerBehavior as well.

Similarly to CompoundSelectionBehavior, one can select using the keyboard or touch, which calls select_node() or deselect_node(), or one can call these methods directly. When a item is selected or deselected apply_selection() is called. See apply_selection().

apply_selection(index, view, is_selected)[source]

Applies the selection to the view. This is called internally when a view is displayed and it needs to be shown as selected or as not selected.

It is called when select_node() or deselect_node() is called or when a view needs to be refreshed. Its function is purely to update the view to reflect the selection state. So the function may be called multiple times even if the selection state may not have changed.

If the view is a instance of RecycleDataViewBehavior, its apply_selection() method will be called every time the view needs to refresh the selection state. Otherwise, the this method is responsible for applying the selection.

Parameters:
index: int

The index of the data item that is associated with the view.

view: widget

The widget that is the view of this data item.

is_selected: bool

Whether the item is selected.

key_selection

The key used to check whether a view of a data item can be selected with touch or the keyboard.

key_selection is the key in data, which if present and True will enable selection for this item from the keyboard or with a touch. When None, the default, not item will be selectable.

key_selection is a StringProperty and defaults to None.

Note

All data items can be selected directly using select_node() or deselect_node(), even if key_selection is False.

class kivy.uix.recycleview.layout.RecycleLayoutManagerBehavior[source]

Bases: object

A RecycleLayoutManagerBehavior is responsible for positioning views into the RecycleView.data within a RecycleView. It adds new views into the data when it becomes visible to the user, and removes them when they leave the visible area.

compute_visible_views(data, viewport)[source]

viewport is in coordinates of the layout manager.

get_view_index_at(pos)[source]

Return the view index on which position, pos, falls.

pos is in coordinates of the layout manager.

goto_view(index)[source]

Moves the views so that the view corresponding to index is visible.

key_viewclass

See RecyclerView.key_viewclass.

refresh_view_layout(index, layout, view, viewport)[source]

See :meth:`~kivy.uix.recycleview.views.RecycleDataAdapter.refresh_view_layout.

set_visible_views(indices, data, viewport)[source]

viewport is in coordinates of the layout manager.

viewclass

See RecyclerView.viewclass.