material cardview 和 just cardview 有什么区别?为什么有些属性不适用?

What is difference of material cardview and just cardview? and why some attrs do not applied?

例如,我将海拔属性添加到 MaterialCardView,但它不起作用。并且使用 background.xml 进行自定义也不起作用。为什么会发生。什么更好用?他们之间

包含有关卡片视图和 material 卡片视图差异的有用信息。 并回答第二个问题: 使用 material 个组件需要 material 个组件主题。 确保在您的项目中使用 material 主题以便能够自定义视图。

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

最大的区别是 MaterialShapeDrawable as background implementing some Material features, such as shaping and elevation overlays 用于深色主题。
MaterialCardView 也支持 checking and dragging.

关于海拔使用app:cardElevation属性。
关于 背景 检查你的 log.You 应该有一个 info message: "Setting a custom background is not supported."

关于海拔,请改用app:cardElevation 关于背景,使用app:cardBackgroundColor