ListItemLayout

A container layout for a List item.

This layout applies the following states according to its position in a list:

  • android.R.attr.state_first
  • android.R.attr.state_last
  • android.R.attr.state_middle
  • android.R.attr.state_single

Children of ListItemLayout that wish to be affected by the ListItemLayout's position state should duplicate the state through setting android.R.attr.duplicateParentState to true.

MaterialCardView is recommended as a ListItemLayout child, as it supports updating its shape / corners based on states.

ListItemLayout supports swipe-to-reveal via a single SwipeableListItem and up to 2 RevealableListItems. The SwipeableListItem and RevealableListItems must be direct children of the ListItemLayout. RevealableListItems can be set to the start or end of the SwipeableListItem via android:layout_gravity. There cannot be more than 1 RevealableListItem with the same layout_gravity.

Constructors

Link copied to clipboard
constructor(@NonNull context: Context)
constructor(@NonNull context: Context, @Nullable attrs: AttributeSet)
constructor(@NonNull context: Context, @Nullable attrs: AttributeSet, defStyleAttr: Int)
constructor(@NonNull context: Context, @Nullable attrs: AttributeSet, defStyleAttr: Int, defStyleRes: Int)

Types

Link copied to clipboard
annotation class Position
Positions for list items.

Properties

Link copied to clipboard
Position for the first item in a list.
Link copied to clipboard
Position for the last item in a list.
Link copied to clipboard
Position for an item in the middle of a list.
Link copied to clipboard
Position for an item that is the only item in a list.
Link copied to clipboard
open val swipeState: Int

Functions

Link copied to clipboard
open fun addView(child: View, index: Int, params: ViewGroup.LayoutParams)
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
open fun onViewRemoved(child: View)
Link copied to clipboard
open fun <T : View?, RevealableListItem?> setSwipeState(swipeState: Int, @NonNull revealView: T)
open fun setSwipeState(swipeState: Int, revealGravity: Int)
open fun <T : View?, RevealableListItem?> setSwipeState(swipeState: Int, @NonNull revealView: T, animate: Boolean)
open fun setSwipeState(swipeState: Int, revealGravity: Int, animate: Boolean)
Sets the state to swipe the SwipeableListItem child to.
Link copied to clipboard
open fun updateAppearance(position: Int)
open fun updateAppearance(position: Int, itemCount: Int)
Helper method that sets the drawable state of the ListItemLayout according to its position in the list.