ListItemRevealLayout


public class ListItemRevealLayout implements RevealableListItem


Layout that is intended to be used as the android.view.ViewGroup that is revealed when a a SwipeableListItem is swiped. This layout always measures its width intrinsically, and uses its direct children's intrinsic width ratios to re-size them accordingly when the layout width changes.

Eg. If ListItemRevealLayout has an intrinsic width of 100 pixels with the first child having an intrinsic width of 20 and the second child having an intrinsic width of 80, when the ListItemRevealLayout changes to a width of 50, the ratios will be kept the same. The first child will have a width of 10 and the second will have a width of 40.

ListItemRevealLayout will be measured at 0 pixels if the desired width is not set.

Summary

Public constructors

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

Public methods

LayoutParams
generateLayoutParams(AttributeSet attrs)
int

Returns the intrinsic width of the RevealableListItem.

int

Sets the minimum width, in pixels, that the children of ListItemRevealLayout can be measured to be.

int

Returns the PrimaryActionSwipeMode for the RevealableListItem that defines the swipe to primary action behavior when swiping with a sibling SwipeableListItem.

void

Resets the intrinsic width remembered by the ListItemRevealLayout.

void
setMinChildWidth(int minChildWidth)

Sets the minimum width, in pixels, that the children of ListItemRevealLayout can be measured to be.

void
setPrimaryActionSwipeMode(int primaryActionSwipeMode)

Sets the swipe-to-primary-action behavior of this RevealableListItem when swiping with a sibling SwipeableListItem.

void
setRevealedWidth(int revealedWidth)

Sets the revealed width of RevealableListItem, in pixels.

Protected methods

LayoutParams
LayoutParams
generateLayoutParams(LayoutParams p)
void
onLayout(boolean changed, int l, int t, int r, int b)
void
onMeasure(int widthMeasureSpec, int heightMeasureSpec)

Inherited Constants

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

When swiping with a sibling SwipeableListItem, swipe directly to the primary action.

static final int

Disable the primary action.

static final int

When swiping with a sibling SwipeableListItem, allow swiping to intermediary states before the primary action.

Inherited methods

From com.google.android.material.listitem.RevealableListItem
abstract void
setPrimaryActionSwipeMode(int swipeToPrimaryActionMode)

Sets the PrimaryActionSwipeMode for the RevealableListItem that defines the swipe to primary action behavior when swiping with a sibling SwipeableListItem.

Public fields

intrinsicWidth

public int intrinsicWidth

minChildWidth

public int minChildWidth

primaryActionSwipeMode

public int primaryActionSwipeMode

Public constructors

ListItemRevealLayout

public ListItemRevealLayout(Context context)

ListItemRevealLayout

public ListItemRevealLayout(Context context, AttributeSet attrs)

ListItemRevealLayout

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

ListItemRevealLayout

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

Public methods

generateLayoutParams

public LayoutParams generateLayoutParams(AttributeSet attrs)

getIntrinsicWidth

public int getIntrinsicWidth()

Returns the intrinsic width of the RevealableListItem. This may be 0 if an intrinsic width has not yet been measured.

getMinChildWidth

public int getMinChildWidth()

Sets the minimum width, in pixels, that the children of ListItemRevealLayout can be measured to be.

getPrimaryActionSwipeMode

public int getPrimaryActionSwipeMode()

Returns the PrimaryActionSwipeMode for the RevealableListItem that defines the swipe to primary action behavior when swiping with a sibling SwipeableListItem.

resetIntrinsicWidth

public void resetIntrinsicWidth()

Resets the intrinsic width remembered by the ListItemRevealLayout. This will cause a re-measure of the ListItemRevealLayout and its children, and should only be called when a re-measure is necessary due to a width change in the layout or any of its children (eg. if a child's visibility changes).

setMinChildWidth

public void setMinChildWidth(int minChildWidth)

Sets the minimum width, in pixels, that the children of ListItemRevealLayout can be measured to be.

setPrimaryActionSwipeMode

public void setPrimaryActionSwipeMode(int primaryActionSwipeMode)

Sets the swipe-to-primary-action behavior of this RevealableListItem when swiping with a sibling SwipeableListItem.

Use onSwipeStateChanged to listen for when the primary action is triggered to initiate the action.

setRevealedWidth

public void setRevealedWidth(int revealedWidth)

Sets the revealed width of RevealableListItem, in pixels.

Protected methods

generateDefaultLayoutParams

protected LayoutParams generateDefaultLayoutParams()

generateLayoutParams

protected LayoutParams generateLayoutParams(LayoutParams p)

onLayout

protected void onLayout(boolean changed, int l, int t, int r, int b)

onMeasure

protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec)