for example I added elevation attr to MaterialCardView
, but it doesn't work. and also customizing with background.xml
doesn't work. why it happens. and what is better to use? between them

- 1,048,767
- 296
- 4,058
- 3,343

- 159
- 1
- 10
-
Can you update your question with the code you tried ...? – AgentP May 23 '20 at 14:27
3 Answers
This link has usefull information about difference of card view and material card view . and answer to second question : Using material components require material components theme. Make sure to use material theme in your project to be able to customize view.
<resources>
<!-- inherit from the material theme -->
<style name="AppTheme" parent="Theme.MaterialComponents.Light.NoActionBar">
<!-- Main theme colors -->
<!-- your app branding color for the app bar -->
<item name="android:colorPrimary">@color/primary</item>
<!-- darker variant for the status bar and contextual app bars -->
<item name="android:colorPrimaryDark">@color/primary_dark</item>
<!-- theme UI controls like checkboxes and text fields -->
<item name="android:colorAccent">@color/accent</item>
</style>
</resources>

- 2,231
- 3
- 21
- 41
The biggest difference is the use of a MaterialShapeDrawable
as background implementing some Material features, such as shaping and elevation overlays for Dark Themes.
Also MaterialCardView
supports checking and dragging.
About the elevation use the app:cardElevation
attribute.
About the background check your log.You should have an info message: "Setting a custom background is not supported."

- 320,139
- 94
- 887
- 841
about the elevation,use app:cardElevation
instead
and about background,use app:cardBackgroundColor

- 71
- 3