Join us on the livestream at Android Dev Summit on 7-8 November 2018, starting at 10AM PDT!

MaterialCardView

public class MaterialCardView
extends CardView

java.lang.Object
   ↳ android.view.View
     ↳ android.view.ViewGroup
       ↳ android.widget.FrameLayout
         ↳ android.support.v7.widget.CardView
           ↳ com.google.android.material.card.MaterialCardView


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.

Summary

Inherited constants

From class android.view.ViewGroup
From class android.view.View

Inherited fields

From class android.view.View

Public constructors

MaterialCardView(Context context)
MaterialCardView(Context context, AttributeSet attrs)
MaterialCardView(Context context, AttributeSet attrs, int defStyleAttr)

Public methods

int getStrokeColor()

Returns the stroke color of this card view.

int getStrokeWidth()

Returns the stroke width of this card view.

void setRadius(float radius)
void setStrokeColor(int strokeColor)

Sets the stroke color of this card view.

void setStrokeWidth(int strokeWidth)

Sets the stroke width of this card view.

Inherited methods

From class android.support.v7.widget.CardView
From class android.widget.FrameLayout
From class android.view.ViewGroup
From class android.view.View
From class java.lang.Object
From interface android.view.ViewParent
From interface android.view.ViewManager
From interface android.graphics.drawable.Drawable.Callback
From interface android.view.KeyEvent.Callback
From interface android.view.accessibility.AccessibilityEventSource

Public constructors

MaterialCardView

MaterialCardView (Context context)

Parameters
context Context

MaterialCardView

MaterialCardView (Context context, 
                AttributeSet attrs)

Parameters
context Context

attrs AttributeSet

MaterialCardView

MaterialCardView (Context context, 
                AttributeSet attrs, 
                int defStyleAttr)

Parameters
context Context

attrs AttributeSet

defStyleAttr int

Public methods

getStrokeColor

int getStrokeColor ()

Returns the stroke color of this card view.

Returns
int

getStrokeWidth

int getStrokeWidth ()

Returns the stroke width of this card view.

Returns
int

setRadius

void setRadius (float radius)

Parameters
radius float

setStrokeColor

void setStrokeColor (int strokeColor)

Sets the stroke color of this card view.

Parameters
strokeColor int: The color of the stroke.

setStrokeWidth

void setStrokeWidth (int strokeWidth)

Sets the stroke width of this card view.

Parameters
strokeWidth int: The width in pixels of the stroke.