~/blog / cardview-vs-materialcardview.md
CardView Vs MaterialCardView: Which One Should You Use?
A detailed comparison between CardView and MaterialCardView in Android, helping you choose the right component for your app.
Both CardView and MaterialCardView are used to display content in a card format, but they have some key differences.
CardView
CardView is part of the AndroidX library and provides a simple card layout with:
- Corner radius
- Elevation (shadow)
- Background color
xml
<androidx.cardview.widget.CardView
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:cardCornerRadius="8dp"
app:cardElevation="4dp">
<!-- Content here -->
</androidx.cardview.widget.CardView>MaterialCardView
MaterialCardView extends CardView and adds Material Design features:
- Stroke/border support
- Checkable state
- Ripple effect
- Shape theming
xml
<com.google.android.material.card.MaterialCardView
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:cardCornerRadius="8dp"
app:strokeWidth="1dp"
app:strokeColor="@color/stroke_color"
app:checkedIcon="@drawable/ic_check">
<!-- Content here -->
</com.google.android.material.card.MaterialCardView>Key Differences
| Feature | CardView | MaterialCardView |
|---|---|---|
| Stroke/Border | No | Yes |
| Checkable | No | Yes |
| Shape Theming | No | Yes |
| Ripple Effect | Manual | Built-in |
When to Use What?
- Use CardView for simple card layouts without Material Design requirements
- Use MaterialCardView when you need Material Design features or interactive cards
Conclusion
For modern Android apps following Material Design guidelines, MaterialCardView is the better choice. It provides more features out of the box and integrates well with the Material Design system.