1

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

Martijn Pieters
  • 1,048,767
  • 296
  • 4,058
  • 3,343
임세준
  • 159
  • 1
  • 10

3 Answers3

1

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>
Zahra
  • 2,231
  • 3
  • 21
  • 41
1

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."

Gabriele Mariotti
  • 320,139
  • 94
  • 887
  • 841
1

about the elevation,use app:cardElevation instead and about background,use app:cardBackgroundColor