ListItemCardView


public class ListItemCardView extends MaterialCardView implements SwipeableListItem


A MaterialCardView that is styled as a list item and can be swiped in a ListItemLayout with a sibling RevealableListItem.

Summary

Nested types

public abstract class ListItemCardView.SwipeCallback

Callback for changes to the SwipeState of the ListItemCardView.

Public fields

final int

Public constructors

ListItemCardView(Context context)
ListItemCardView(Context context, AttributeSet attrs)
ListItemCardView(Context context, AttributeSet attrs, int defStyleAttr)
ListItemCardView(
    Context context,
    AttributeSet attrs,
    int defStyleAttr,
    int defStyleRes
)

Public methods

void

Add a callback to be invoked when the swipe state of the SwipeableListItem changes.

int

Returns the overshoot, in pixels, that the SwipeableListItem is able to be swiped past the STATE_OPEN or STATE_SWIPE_PRIMARY_ACTION states by, before settling.

boolean

Whether or not to allow the SwipeableListItem to be swiped.

void
onSwipe(int swipeOffset)

Called when the position of the SwipeableListItem changes.

void
<T extends View & RevealableListItem> onSwipeStateChanged(
    int swipeState,
    T revealableListItem,
    int revealGravity
)

Callback for when the swipe state of the SwipeableListItem changes.

void

Remove the specified callback from being called when the swipe state of the SwipeableListItem changes.

void
setSwipeEnabled(boolean swipeEnabled)

Whether or not to enabling swiping when there is a sibling RevealableListItem.

Protected methods

int[]
onCreateDrawableState(int extraSpace)

Inherited Constants

From com.google.android.material.card.MaterialCardView
static final int

Gravity used to position the checked icon at the bottom|end of the Card.

static final int

Gravity used to position the checked icon at the bottom|start of the Card.

static final int

Gravity used to position the checked icon at the top|end of the Card.

static final int

Gravity used to position the checked icon at the top|start of the Card.

From com.google.android.material.listitem.SwipeableListItem
static final int

The state at which the associated RevealableListItem is closed and nothing is revealed.

static final int

The state at which the SwipeableListItem is being dragged.

static final int

The state at which the associated RevealableListItem is revealed to its intrinsic width.

static final int

The state at which the SwipeableListItem is settling to the nearest settling point.

static final int

The state at which the SwipeableListItem is fully swiped, meaning the primary action has been committed.

Inherited methods

From com.google.android.material.card.MaterialCardView
ColorStateList
ColorStateList

Sets the ripple color for this card.

Drawable

Returns this cards's checked icon.

int

Gets the checked icon gravity for this card

int
int
ColorStateList

Returns the android.content.res.ColorStateList used to tint the checked icon.

int
int
int
int
float

Returns the interpolation on the Shape Path of the card.

float
ColorStateList

Gets the ripple color for this card.

ShapeAppearanceModel

Due to limitations in the current implementation, if you modify the returned object call setShapeAppearanceModel again with the modified value to propagate the required changes.

int

This method is deprecated.

use getStrokeColorStateList

ColorStateList

Returns the stroke ColorStateList of this card view.

int

Returns the stroke width of this card view.

boolean

Returns whether this Card is checkable.

boolean
boolean
void
void
onInitializeAccessibilityEvent(AccessibilityEvent accessibilityEvent)
void
onInitializeAccessibilityNodeInfo(AccessibilityNodeInfo info)
void
onMeasure(int widthMeasureSpec, int heightMeasureSpec)
void
setBackground(Drawable drawable)
void
setBackgroundDrawable(Drawable drawable)
void
setCardBackgroundColor(ColorStateList color)
void
void
setCardElevation(float elevation)
void
setCardForegroundColor(ColorStateList foregroundColor)

Sets the foreground color for this card.

void
setCheckable(boolean checkable)

Sets whether this Card is checkable.

void
setChecked(boolean checked)
void
setCheckedIcon(Drawable checkedIcon)

Sets this card's checked icon.

void

Sets the checked icon gravity for this card

void
setCheckedIconMargin(int checkedIconMargin)
void
setCheckedIconMarginResource(int checkedIconMarginResId)

Sets the margin of the checked icon using a resource id.

void

Sets this card's checked icon using a resource id.

void
setCheckedIconSize(int checkedIconSize)

Sets the size of the checked icon

void
setCheckedIconSizeResource(int checkedIconSizeResId)

Sets the size of the checked icon using a resource id.

void
setCheckedIconTint(ColorStateList checkedIconTint)

Sets this checked icon color tint using the specified android.content.res.ColorStateList.

void
setClickable(boolean clickable)
void
setContentPadding(int left, int top, int right, int bottom)
void
setDragged(boolean dragged)

Call this when the Card is being dragged to apply the right color and elevation changes.

void
setMaxCardElevation(float maxCardElevation)
void

Register a callback to be invoked when the checked state of this Card changes.

void
setPreventCornerOverlap(boolean preventCornerOverlap)
void
setProgress(float progress)

Sets the interpolation on the Shape Path of the card.

void
setRadius(float radius)
void
setRippleColor(ColorStateList rippleColor)

Sets the ripple color for this card.

void
setRippleColorResource(int rippleColorResourceId)

Sets the ripple color resource for this card.

void

Sets the ShapeAppearanceModel that defines the shape.

void
setStrokeColor(ColorStateList strokeColor)

Sets the stroke color of this card view.

void
setStrokeColor(int strokeColor)

Sets the stroke color of this card view.

void
setStrokeWidth(int strokeWidth)

Sets the stroke width of this card view.

void
setUseCompatPadding(boolean useCompatPadding)
void

Public fields

swipeMaxOvershoot

public final int swipeMaxOvershoot

Public constructors

ListItemCardView

public ListItemCardView(Context context)

ListItemCardView

public ListItemCardView(Context context, AttributeSet attrs)

ListItemCardView

public ListItemCardView(Context context, AttributeSet attrs, int defStyleAttr)

ListItemCardView

public ListItemCardView(
    Context context,
    AttributeSet attrs,
    int defStyleAttr,
    int defStyleRes
)

Public methods

addSwipeCallback

public void addSwipeCallback(ListItemCardView.SwipeCallback callback)

Add a callback to be invoked when the swipe state of the SwipeableListItem changes.

getSwipeMaxOvershoot

public int getSwipeMaxOvershoot()

Returns the overshoot, in pixels, that the SwipeableListItem is able to be swiped past the STATE_OPEN or STATE_SWIPE_PRIMARY_ACTION states by, before settling.

isSwipeEnabled

public boolean isSwipeEnabled()

Whether or not to allow the SwipeableListItem to be swiped.

onSwipe

public void onSwipe(int swipeOffset)

Called when the position of the SwipeableListItem changes.

onSwipeStateChanged

public void <T extends View & RevealableListItem> onSwipeStateChanged(
    int swipeState,
    T revealableListItem,
    int revealGravity
)

Callback for when the swipe state of the SwipeableListItem changes.

Parameters
int swipeState

The new SwipeState of the SwipeableListItem.

T revealableListItem

The associated RevealableListItem that is being revealed when swiped. If the new state is STATE_CLOSED, this will be the last active RevealableListItem.

int revealGravity

The RevealGravity of the revealableListItem.

removeSwipeCallback

public void removeSwipeCallback(ListItemCardView.SwipeCallback callback)

Remove the specified callback from being called when the swipe state of the SwipeableListItem changes.

setSwipeEnabled

public void setSwipeEnabled(boolean swipeEnabled)

Whether or not to enabling swiping when there is a sibling RevealableListItem.

Protected methods

onCreateDrawableState

protected int[] onCreateDrawableState(int extraSpace)