A view for displaying
A slice is a piece of app content and actions that can be surfaced outside of the app it
originates from. SliceView is able to interpret the structure and contents of a slice and display
it. This structure is defined by the app providing the slice when the slice is constructed with a
SliceView is able to display slices in a couple of different modes via .
- Small: The small format has a restricted height and display top-level information and actions from the slice.
- Large: The large format displays as much of the slice as it can based on the space provided for SliceView, if the slice overflows the space SliceView will scroll the content if scrolling has been enabled on SliceView, .
- Shortcut: A shortcut shows minimal information and is presented as a tappable icon representing the main content or action associated with the slice.
Slices can contain dynamic content that may update due to user interaction or a change in the
data being displayed in the slice. SliceView can be configured to listen for these updates easily
SliceLiveData. Example usage:
SliceView v = new SliceView(getContext()); v.setMode(desiredMode); LiveData
liveData = SliceLiveData.fromUri(sliceUri); liveData.observe(lifecycleOwner, v);
SliceView supports various style options, see
Implement this interface to be notified of interactions with the slice displayed in this view.
Mode indicating this slice should be presented in large format, as much or all of the slice contents are shown.
Mode indicating this slice should be presented as a tappable icon.
Mode indicating this slice should be presented in small format, only top-level information and actions from the slice are shown.