Material Card View
Provides a Material card.
This class supplies Material styles for the card in the constructor. The widget will display the correct default Material styles without the use of a style flag.
Stroke width can be set using the strokeWidth
attribute. Set the stroke color using the strokeColor
attribute. Without a strokeColor
, the card will not render a stroked border, regardless of the strokeWidth
value.
Cards implement Checkable, a default way to switch to android:checked_state
is not provided. Clients have to call setChecked. This shows the
app:checkedIcon
and changes the overlay color.
Cards also have a custom state meant to be used when a card is draggable
app:dragged_state
. It's used by calling setDragged. This changes the overlay color and elevates the card to convey motion.
Note: The actual view hierarchy present under MaterialCardView is NOT guaranteed to match the view hierarchy as written in XML. As a result, calls to getParent() on children of the MaterialCardView, will not return the MaterialCardView itself, but rather an intermediate View. If you need to access a MaterialCardView directly, set an
android:id
and use findViewById.
For more information, see the component developer guidance and design guidelines.