belongs to Maven artifact androidx.car:car:1.0.0-alpha1

ListItemBackgroundResolver

public class ListItemBackgroundResolver
extends Object

java.lang.Object
   ↳ androidx.car.utils.ListItemBackgroundResolver


A utility class that will set the current background for a View that represents an card entry in a list. The class will set the background depending on the position of the card within the list.

Summary

Public methods

static void setBackground(View view, int currentPosition, int totalItems)

Sets the background on the given view so that the combination of all items looks like a rectangle with rounded corner.

Inherited methods

Public methods

setBackground

void setBackground (View view, 
                int currentPosition, 
                int totalItems)

Sets the background on the given view so that the combination of all items looks like a rectangle with rounded corner. The view is assumed to have a non-rounded corner outline.

The view will be set with rounded backgrounds if it is the only card within the list. Or if it is the first or last view, it will have the top or bottom corners rounded respectively.

Parameters
view View: The view whose background to set.

currentPosition int: The current position of the View within the list. This value should be 0-based.

totalItems int: The total items within the list.